;**************************************************
;MAKEAUTO.ASM   version 1.0      9/10/82
;
;copyright 1982 by M. Joel Guerra
;portions copyright 1981 by Thom Hogan
;
;This program creates a new AUTOST.COM file on disk
;for use with the Osborne 1 computer
;**************************************************
;
;
cr 	equ	0dh	;carriage return
lf	equ	0ah	;line feed
clr	equ	26	;clear Osborne screen
;
;
	org	100h
	jmp	200h
	mvi	l,00h
	mov	a,h
	sui	16h
	mov	h,a
	shld	0110h
	jmp	main
	nop
	nop
	nop
print:	mvi	c,09
	jmp	0005h
rpt:	ldax	d
	mov	m,a
	inx	h
	inx	d
	dcx	b
	mov	a,b
	ora	c
	jnz	rpt
	ret
main:	lxi	d,signon
	call	print
	lxi	d,prgm
cntr:	lxi	b,0
	lhld	0110h
	mvi	l,07
	call	rpt
	lhld	0110h
	mvi	l,88h
	mvi	a,08h
	mov	m,a
	lhld	0110h
	mvi	l,89h
	mov	a,h
	mov	m,a
	lhld	0110h
	pchl
pprgm:	db	018h
prgm:	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
signon:	db	clr,cr,lf,lf,lf
	db	lf,lf,lf,lf,lf,lf,52,0
smesg:	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,0,0,0
	db	0,0,0,0,0,cr,lf,lf,'$'
	ds	87
;
;
	org	200h
;
	lxi	h,0100h
	mvi	m,02ah
	inr	l
	mvi	m,01
	inr	l
	mvi	m,00
;
	lxi	d,msg1
	call	print
;
;	fetch the name of the program to autostart
;
	lxi	d,pprgm
	mvi	c,0ah
	call	0005h
;
;	fetch the autostart message to be displayed
;
	lxi	d,msg2
	call	print
;
	lxi	d,smesg-2
	mvi	c,0ah
	call	0005h
;
	lda	prgm
	inr	a
	inr	a
	sta	cntr+1
;
	mvi	a,lf
	sta	smesg-2
	sta	smesg-1
;
;	Save the new AUTOST.COM program on the b: disk
;
	lxi	d,msg3
	call	print
	lxi	d,bsave		;delete any previous file
	mvi	c,013h
	call	0005h
	lxi	d,bsave		;open new AUTOST.COM file
	mvi	c,016h
	call	0005h
	inr	a
	jz	fuldir
	lxi	d,0100h		;set DMA address
	mvi	c,01ah
	call	0005h
	lxi	d,bsave		;start writing to disk
	mvi	c,015h
	call	0005h
	ora	a
	jnz	fuldsk
	lxi	d,0180h		;set DMA address AGAIN!
	mvi	c,01ah
	call	0005h
	lxi	d,bsave		;finish writing to disk
	mvi	c,015h
	call	0005h
	lxi	d,bsave		;close file, write FCB to disk
	mvi	c,010h
	call	0005h
	lxi	d,msg6
	call	print
	jmp	0000h
;
fuldir:	lxi	d,msg4
	call	print
	jmp	0000h
fuldsk:	lxi	d,msg5
	call	print
	jmp	0000h
;
bsave:	db	2,'AUTOST  COM',0,0,0,0
	db	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	db	0,0,0,0
;
msg1:	db	clr,cr,lf,lf,lf
	db	9,'THE AUTOST.COM MAKER'
	db	cr,lf,9,'     Version 1.0'
	db	cr,lf,lf,lf
	db	'This program takes your inputs and creates',cr,lf
	db	'an "AUTOST.COM" file on the B: drive.',cr,lf
	db	lf,'For this reason, please put the disk you',cr,lf
	db	'want to autostart in the B: drive.',cr,lf
	db	'(It is assumed that this program was loaded',cr,lf
	db	'from the A: drive.)',cr,lf,lf
	db	'Type in the name of the program as if you',cr,lf
	db	'were going to run it under CP/M.',cr,lf
	db	'(You MUST use CAPITAL LETTERS here.)',cr,lf,lf
	db	'      Examples:  (not more than 24 characters)',cr,lf
	db	'A>MBASIC PROGRAM<cr>    for a MBASIC program; or',cr,lf
	db	'A>SORT<cr>    for Supersort (tm) by MicroPro.',cr,lf,lf
	db	'A>$'
msg2:	db	clr,cr,lf,lf,lf
	db	'Now, type a one-line message for the sign-on',cr,lf
	db	'display. You can have up to 52 characters on',cr,lf
	db	'the line (a TAB counts as one character).',cr,lf
	db	lf,'I recommend a TAB for the first character.',cr,lf
	db	'You can edit the line, but hitting the carriage',cr,lf
	db	'return key will enter the line.',cr,lf,lf,lf,'$'
msg3:	db	cr,lf,lf,lf,'   NOW SAVING B:AUTOST.COM...',cr,lf,'$'
msg6:	db	lf,'   (The disk should be ready for self-starting',cr,lf
	db	'   when the light goes off on the drive.  Press',cr,lf
	db	'   RESET and put the disk in the left drive,',cr,lf
	db	'   hit the return key, and watch what happens.)',cr,lf
	db	lf,'   BE SURE THE CP/M SYSTEM IS ON THE DISK.',cr,lf
	db	'$'
msg4:	db	cr,lf,lf,'Sorry, but there is no directory space left',cr,lf
	db	'on your B: disk.',cr,lf,'$'
msg5:	db	cr,lf,lf,'Sorry, but there is no room left on your disk.'
	db	cr,lf,'$'
