;	This file loads Z-MSG.COM and uses the MENTER.OVR to init name..
;
; Use Aztec's assembler/linker to assemble this
;
;	10/10/85 MENTR.COM
;
; There are inexcusable hacks in this file.. forgive me.
; It is expected that this be called MENTR.COM, and is the file loaded
; by BYE as a caller comes in.  This is required because something MUST
; be in the command line (default dma 80h buffer) to indicate that the
; name/id enter program be run, OTHERWISE the message system will read
; the lastcalr file and use the last users ID.
;
user	equ	0	; user area to get metal.com from....

	org	100h

;lxi	h,0
;push	h		; ret forces to warm boot

	lxi	h,005ch		; default fcb
fcbloop1:
	mvi	m,0 
	inx	h
	mov	a,l
	cpi	80h
	jnz	fcbloop1

	lxi	h,005dh		; where to put name of file
	lxi	d,fname
fcbloop2:
	ldax	d
	ora	a
	jz	done
	mov	m,a
	inx	h
	inx	d
	jmp	fcbloop2
;
fname:	db	'METAL   COM',0
;
done:
	mvi	c,20h		; set user func
	mvi	e,user
	call	0005		; bdos
	mvi	c,0fh		; open code..
	lxi	d,005ch		; fcb
	call	0005		; bdos
	cpi	0ffh		; error?
	jz	0		; yes boot...
	lxi	d,loader
	lxi	h,0080h		; dma..
	lxi	b,07fh
movloop:
	ldax	d
	mov	m,a
	inx	d
	inx	h
	dcr	c
	jnz	movloop
	lxi	b,005ch		; fcb
	jmp	080h+loadrun-loader	; jump to loader...
;
loader:
	db	10
	db	'run menter'	; command line..REQUIRED and <=14 chars
	db	0

loadrun:
	lxi	d,100h		; tpa
load1:
	push	d
	push	b
	mvi	c,1ah		; set dma..
	call	0005		; bdos
	pop	d
	push	d
	mvi	c,14h		; read seq.
	call	0005		; bdos
	pop	b
	pop	d

	ora	a		; error?
	jz	80h+(bumpdma-loader)	; jrz bumpdma
a1:	mvi	c,1ah		; set dma
	lxi	d,0080h		; reset default dma address..
	call	0005		; bdos
	mvi	c,10h		; close
	lxi	d,05ch
	call	0005
	db	0,0,0,0,0

	jmp	100h		; tpa.. (program just loaded)

;
bumpdma:
	lxi	h,0080h
	dad	d
	xchg
	jmp	80h+(load1-loader)	; jr loader
;
lend:	db	0
	END
