	TITLE  'NORTH STAR SECRTARY AS OF 0308A'

;COPYRIGHT 1979, G. YOUNG, PO BOX 3218, NORTH HOLLYWOOD, CA 91609
;PERMISSION GRANTED TO COPY FOR ANY NON-COMMERCIAL USE ONLY.



NS	EQU	2000H		;NORTH STAR SYSTEM BEGINS AT 2000
DCOM	EQU	NS+22H
COUT	EQU	NS+0DH
CIN	EQU	NS+10H
CONTC	EQU	NS+16H
DOS	EQU	NS+28H
DLOOK	EQU	NS+1CH
DLIST	EQU	NS+25H
DOSER	EQU	NS+2DH
RWCHK	EQU	NS+2BH
DBYTE	EQU	NS+2FH
DWRIT	EQU	NS+1FH
PART1	EQU	NS+0D00H
	ORG	PART1
	JMP	INITA
	DB	0
	JMP	EOR		;RESTART WITHOUT RESETTING
ASSMB	DB	'  0308A',13
	DB	'COPYRIGHT 1979, G. YOUNG, INC'
DENTY	DB	'S'
BSPCH	DB	08
STOP	DB	0
SRCNT	DB	23
FLG1	DB	'N'
HTOT	DB	0
DATA0	DW	MEMRY
BSCR	DB	'C'
LNSIZ	DB	78
WRAP	DB	'Y'
MEMTP	DW	07FFFH
CLEAN	LXI	H,BOFP
	MVI	C,255
	XRA	A
CLRM	MOV	M,A
	INX	H
	DCR	C
	JNZ	CLRM
	LHLD	DATA0
	SHLD	BOFP
	SHLD	EOFP
	LHLD	MEMTP
	SHLD	TOP
	MVI	A,70
	STA	LINES
	MVI	A,0FFH
	STA	PNO
	MVI	A,1
	LHLD	BOFP
	MOV	M,A
	MVI	A,66
	STA	PAGE1
	MVI	A,54
	STA	PAGE2
	MVI	A,7
	STA	PAGE3
	LDA	BSPCH
	STA	X5F2+1
	STA	X5F1+1
	STA	X5F3+1
	LDA	LNSIZ
	STA	CPI80+1
	SUI	7
	STA	CPI74+1
	RET
INITA	LXI	SP,AREA+50
	LXI	SP,AREA+50
	CALL	CLEAN
	CALL	CRLF
	LXI	SP,AREA+50
	LXI	H,SMESS
	CALL	SCRN
	LXI	H,ASSMB
	CALL	SCRN
	LX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DW	DUMP1
	DB	'EDIT'
	DW	EDIT
	DB	'EXPA'
	DW	EXPAND
	DB	'FIND'
	DW	FINDCMND
	DB	'FREE'
	DW	FREE
	DB	'HELP'
	DW	HELP
	DB	'JUST'
	DW	JUSTCMND
	DB	'LINE'
	DW	LINECMND
	DB	'LIST'
	DW	LIST
	DB	'LOAD'
	DW	LOAD
	DB	'MARG'
	DW	MARGINCMND
	DB	'MERG'
	DW	MERGECMND
	DB	'MOVE'
	DW	MOVECMND
	DB	'NSAV'
	DW	NSAVE
	DB	'NULL'
	DW	NULLCMND
	DB	'OFFS'
	DW	OFFSETCMND
	DB	'OPEN'
	DW	OPENCMND
	DB	'PAGE'
	DW	PAGECMND
	DB	'PNUM'
	DW	PNUMCMND
	DB	'PRIN'
	DW	PRINT
	DB	'QUIT'
	DW	QUIT
	DB	'RECO'
	DW	RECOVER
	DB	'RENU'
	DW	RENUMBER
	DB	'REPE'
	DW	REPEATCMND
	DB	'SAVE'
	DW	SAVECMND
	DB	'SCRA'
	DW	SCRAT
	DB	'SPAC'
	DW	SPACECMND
	DB	'STAT'
STATUS	DW	STATCMND
	DB	'TABS'
	DW	TABSCMND
	DB	'TITL'
	DW	TITLECMND
	DB	'UNIT'
	DW	UNITCMND
	DB	'DEBU'
	DW	DEBUG
QUIT	CALL	CRLF
	LXI	H,QUITM
	CALL	SCRN
	CALL	CRLF
	JMP	DOS
EXPAND	LXI	H,DATA
	SHLD	DATA0
	LXI	H,EOR
	SHLD	BLOAD
	SHLD	BSAVE
	SHLD	STATUS
	SHLD	CONFG
	SHLD	CNG2+1
	CALL	CLEAN
	CALL	FREE1
	JMP	EOR
CALLA	CALL	ETRA
	JC	ERR3
	LHLD	BBUF
	SHLD	CALLD
	LDA	BBUF+2
	STA	CALLC
	LXI	H,CALLP
	JMP	REPLY
CALLT	LXI	D,CALLM
	RET
CALLM	DB	'CALL COMMAND TEST'
	DB	13
CALLP	DB	'CALL COMMAND ACCEPTED'
	DB	13
BHEAD	DB	'  B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ET
ERRM5	DB	'FILE TOO SMALL...NOT SAVED'
	DB	13
ERR6	LXI	H,ERRM6
	STA	BLOCK
	JMP	RPLY
ERRM6	DB	'FILE TOO LARGE TO FIT IN MEMORY...ONLY PARTIALLY LOADED'
	DB	13
;GET	THE	FILE	NAME
GFILE	MVI	A,1
	STA	DISK
	MVI	C,9
	MVI	A,' '
	LXI	D,FILE
BFILL	STAX	D
	INX	D
	DCR	C
	JNZ	BFILL
LOOK1	MOV	A,M
	CPI	13
	JZ	ERR1
	CPI	' '
	JNZ	MFILE
	INX	H
	JMP	LOOK1
MFILE	MVI	C,9
	LXI	D,FILE
FILL1	MOV	A,M
	CPI	13
	JZ	UPPER
	CPI	' '
	JZ	UPPER
	CPI	','
	JZ	LOOKU
	STAX	D
	INX	H
	INX	D
	DCR	C
	JZ	ERR1
	JMP	FILL1
LOOKU	INX	H
	MOV	A,M
	CPI	13
	JZ	UPPER
	CPI	'1'
	JC	ERR1
	CPI	'4'+1	;QD ALLOWS 4 DRIVES
	JNC	ERR1
	ANI	0FH
	STA	DISK
	INX	H
UPPER	LXI	D,FILE
	MVI	B,8
UPPR	LDAX	D
	CPI	60H
	JC	LOWER
	SBI	20H
	STAX	D
LOWER	INX	D
	DCR	B
	JNZ	UPPR
	RET
;	SEE	IF	FILE IS THERE
DIREC	LDA	DISK
	LXI	H,FILE
	CALL	DLOOK
	RNC
	LXI	H,ERR4
	JMP	REPLY
ERR4	DB	'FILE NOT FOUND'
	DB	13
;OUTPUT	NULL	CHARACTERS
NULLO	LDA	NULLC
	ORA	A
	RZ
	PUSH	D
	MOV	E,A
NULL2	MVI	B,0
	CALL	OUT8A
	DCR	E
	JNZ	NULL2
NULL3	POP	D
	RET
;OUTPUT	A	CARRIAGE	RETURN LINE FEED
CRLF	MVI	B,13
	CALL	OUT8
	MVI	B,10
	CALL	OUT8
	CALL	NULLO
	RET
;CHARACTER	INPUT	ROUTINE
IN8	XRA	A
	JMP	CIN
;ECHOE	TAB	CHAR	AS @
;O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	GPARM
	STA	OFFST
	LXI	H,MESSO
	JMP	REPLY
MESSO	DB	'OFFSET ACCEPTED'
	DB	13
MARGINCMND	EQU	$
MARGN	CALL	SETUP
	CALL	GPARM
	ORA	A
	JZ	ERR2
	DCR	A
	STA	OFFST
	CALL	GPARM
	ORA	A
	JZ	ERR2
	CPI	132
	JNC	ERR2
	MOV	B,A
	LDA	OFFST
	MOV	C,A
	MOV	A,B
	SUB	C
	JC	ERR2
	STA	LINES
	LXI	H,MESSM
	JMP	REPLY
MESSM	DB	'MARGINS SET'
	DB	13
PNUMCMND	EQU	$
SETPN	CALL	SETUP
	CALL	GPARM
	DCR	A
	STA	PNO
	LXI	H,MESSP
	JMP	REPLY
MESSP	DB	'PAGE NO ACCEPTED'
	DB	13
REPEATCMND	EQU	$
REPET	CALL	SETUP
	CALL	GPARM
	STA	RPEAT
	LXI	H,MESSE
	JMP	REPLY
MESSE	DB	'REPEAT COUNT ACCEPTED'
	DB	13
LINECMND	EQU	$
	CALL	SETUP
	CALL	GPARM
	STA	LINES
	LXI	H,MESSF
	JMP	REPLY
MESSF	DB	'CHAR/LINE CHANGED'
	DB	13
SPACECMND	EQU	$
SPACX	CALL	SETUP
	CALL	GPARM
	STA	SPACE
	LXI	H,MESSG
	JMP	REPLY
MESSG	DB	'SPACING CHANGED'
	DB	13
UNITCMND	EQU	$
UNITX	CALL	SETUP
	CALL	GPARM
	STA	UNIT
	LXI	H,MESS7
	JMP	REPLY
MESS7	DB	'PRINT UNIT CHANGED'
	DB	13
PAGECMND	EQU	$
PAGEX	CALL	SETUP
	CALL	GPARM
	ORA	A
	JZ	ERR2
	STA	PAGE1
	CALL	GPARM
	ORA	A
	JZ	OK1
	STA	PAGE2
	CALL	GPARM
	ORA	A
	JZ	OK1
	STA	PAGE3
OK1	LXI	H,MESS8
	JMP	REPLY
MESS8	DB	'PAGE PARMS CHANGED'
	DB	13
TITLECMND	EQU	$
TITLX	CALL	SETUP
	MVI	B,50
	LXI	D,TITLEX
TITL0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B	'DISK I/O ERROR'
	DB	13
;REPLACE	TOKEN	WITH	DBII TEXT
DECOD	LXI	H,BTAB
	MOV	B,A
CODE1	MOV	A,M
	CPI	0FFH
	JZ	CODE6
	CPI	80H
	JNC	CODE2
CODE3	INX	H
	JMP	CODE1
CODE2	CMP	B
	JNZ	CODE3
	INX	H
	XCHG
	LHLD	RECAD
CODE4	LDAX	D
	CPI	80H
	JNC	CODE5	;ON NEXT CODE
	MOV	M,A
	INX	D
	INX	H
	JMP	CODE4
CODE6	LHLD	RECAD
	MOV	A,B
	MOV	M,A
	INX	H
CODE5	SHLD	RECAD
	JMP	LOAD1
;*************		BSAVE	 BSAVE  BSAVE  ****************
BSAVECMND	CALL	GETBF
	CALL	GETFL
	LXI	H,0000
	SHLD	BUFCT
	XRA	A
	STA	RDWRT
	STA	INHIB
	MVI	A,01
	STA	CCNT
	LHLD	BOFP
	SHLD	ADDR1
DECD1	LXI	H,IBUF
	SHLD	ADDR2
	CALL	GETCH
	CPI	01
	JZ	EOFPT5
	CALL	GETCH
	CALL	BINLN
DECD2	CALL	GETCH
	CPI	13
	JZ	ENDLN
	CPI	' '
	JZ	NONUM
	CPI	','
	JZ	NONUM
	CPI	22H
	JZ	QUOTE
	CPI	'0'
	JC	TOKEN
	CPI	'9'+1
	JNC	TOKEN
	JMP	LINEX
QUOTE	PUSH	PSW
	LDA	INHIB
	ORA	A
	JZ	QUOT2
	XRA	A
QUOT3	STA	INHIB
	POP	PSW
	JMP	LINEX
QUOT2	MVI	A,1
	JMP	QUOT3
NONUM	CALL	PUTCH
	JMP	DECD2
LINEX	MOV	B,A
	LDA	LINE1
	ORA	A
	JNZ	GENLN
	MOV	A,B
	CALL	PUTCH
	JMP	DECD2
ENDLN	CALL	PUTCH
	XRA	A
	STA	INHIB
	LDA	CCNT
	STA	IBUF-1
	LHLD	BUFAD
	SHLD	HL
	LXI	B,IBUF-1
	XCHG
	LHLD	BUFCT
ADDLN	LDAX	B
	STAX	D
	INX	B
	INX	D
	IN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(S/D)? '
	DB	13
Q5	DB	'STOP AT END OF EACH PAGE (Y/N)? '
	DB	13
Q6	DB	'LINES PER SCREEN OR ZERO? '
	DB	13
Q7	DB	'LINE WRAP AROUND ON INPUT (Y/N)? '
	DB	13
Q8	DB	'INPUT LINE LENGTH? '
	DB	13
Q10	DB	'UNDERLINE USING BS OR CR (B/C)? '
	DB	13
Q99	DB	'SAVE THIS VERSION OF SECRTARY (Y/N)? '
	DB	13


; STATUS COMMAND SHOWS ALL USER CHANGABLE INDICATORS
STATCMND	CALL	CRLF
	CALL	CRLF		;BLANK LINE BEFORE DISPLAY
	LXI	H,STAT1		;SCREEN SIZE
	CALL	SCRN
	LDA	SRCNT
	INR	A
	CALL	NUMBER
	LXI	H,STAT2
	CALL	SCRN
	LDA	LNSIZ
	DCR	A		;CONFIGURE ADDS 2
	DCR	A	
	CALL	NUMBER
	LXI	H,STAT3		;LINE WRAPAROUND
	CALL	SCRN
	LDA	WRAP
	CALL	ALPHABETIC
	LXI	H,STAT4		;UNDERLINE MODE
	CALL	SCRN
	LDA	BSCR
	CALL	ALPHABETIC
	CALL	CRLF
	LXI	H,STAT5		;STOP AT BOTTOM OF PAGE
	CALL	SCRN
	LDA	STOP
	ORA	A
	JZ	STATUS1
	MVI	A,'Y'
	JMP	STATUS2
STATUS1	MVI	A,'N'
STATUS2	CALL	ALPHABETIC
	LXI	H,STAT6		;DISK DENSITY
	CALL	SCRN
	LDA	DENTY
	CALL	ALPHABETIC
	LXI	H,STAT7		;NULL COUNT
	CALL	SCRN
	LDA	NULLC
	CALL	NUMBER
	LXI	H,STAT19	;OFFSET
	CALL	SCRN
	LDA	OFFST
	CALL	NUMBER
	CALL	CRLF
	LXI	H,STAT8		;PAGE SIZE
	CALL	SCRN
	LDA	PAGE1
	CALL	NUMBER
	LDA	PAGE2
	CALL	NUMBER
	LDA	PAGE3
	CALL	NUMBER
	LXI	H,STAT9		;MARGINS
	CALL	SCRN
	LDA	OFFST
	INR	A
	CALL	NUMBER
	LDA	OFFST
	MOV	B,A
	LDA	LINES
	ADD	B
	CALL	NUMBER
	LXI	H,STAT10	;OUTPUT LINE LENGTH
	CALL	SCRN
	LDA	LINES
	CALL	NUMBER
	CALL	CRLF
	LXI	H,STAT11	;TAB SETTINGS
	CALL	SCRN
	LXI	D,TABT
	MVI	B,10
	LDAX	D
	ORA	A
	JNZ	STATTAB
	LXI	H,STAT99
	CALL	SCRN
	JMP	STATSPC
STATTAB	CALL	NUMBER
	INX	D
	DCR	B
	JZ	STATSPC
	LDAX	D
	ORA	A
	JNZ	STATTAB
STATSPC	LXI	H,STAT12	;SPACING BETWEEN LINES
	CALL	SCRN
	LDA	SPACE
	CALL	NUMBER
	CALL	CRLF
	LXI	H,STAT13	;TITLE
	CALL	SCRN
	LDA	TITLEX
	ORA	A
	JNZ	STATTTL
	LXI	H,STAT99
	CALL	SCRN
	JMP	STATLN6
STATTTL	LXI	H,TITLEX
	CALL	SCRN
STATLN6	CALL	CRLF
	LXI	H,STAT14	;JUSTIFY
	CALL	SCRN
	LDA	JSW
	ORA	A
	JZ	STATJN
	MVI	A,'Y'
	JMP	STATJY
STATJN	MVI	A,'N'
STATJY	CALL	ALPHABETIC
	LXI	H,STAT16	;UNIT
	CALL	SCRN
	LDA	UNIT
	CALL	NUMBER
	LXI	H,STAT17	;REPEAT
	CALL	SCRN
	LDA	RPEAT
	CALL	NUMBER
	LXI	H,STAT18	;PAGE NUMBER--PNUM
	CALL	SCRN
	LDA	PNO
	INR	A
	CALL	NUMBER
	CALL	FREE		;MEMORY UTILIZATION INFO
	CALL	CRLF
	JMP	EOR

NUMBER	EQU	$
	PUSH	H
	PUSH	D
	PUSH	B
	CALL	BLANK
	LXI	H,PN2
	CALL	BIND
	LXI	D,PN2
	LDAX	D
	CPI	'0'		;SKIP LEADING ZEROES
	JNZ	PRTNUMB
	INX	D
	LDAX	D		;SKIP ZEROES
	CPI	'0'
	JNZ	PRTNUMB
	INX	D
PRTNUMB	EQU	$
	XCHG
	CALL	SCRN
	POP	B
	POP	D
	POP	H
	RET

BLANK	PUSH	PSW		;SAVE A REG
	MVI	B,20H
	CALL	OUT8
	POP	PSW
	RET

ALPHABETIC EQU	$		;PRINT 1 ALPHA CHAR IN A
	CALL	BLANK
	MOV	B,A
	JMP	OUT8		;PRINT IT USING OUT8'S RETURN
STAT1	DB	'SCREEN SIZE:',13
STAT2	DB	' X',13
STAT3	DB	'   LINE WRAPAROUND:',13
STAT4	DB	'   UNDERLINE:',13
STAT5	DB	'STOP AT BOTTOM:',13
STAT6	DB	'   DISK DENSITY:',13
STAT7	DB	'   NULLS:',13
STAT8	DB	'PAGE SIZE:',13
STAT9	DB	'   MARGINS:',13
STAT10	DB	'   OUTPUT LINE:',13
STAT11	DB	'TABS:',13
STAT12	DB	'   SPACING:',13
STAT13	DB	'TITLE: ',13
STAT14	DB	'JUSTIFY:',13
STAT16	DB	'   UNIT:',13
STAT17	DB	'   REPEAT:',13
STAT18	DB	'   PNUM:',13
STAT19	DB	'   OFFSET:',13
STAT99	DB	' NONE',13
MEMRY	EQU	$
	END
