@echo off
if "%debug%" == "yes" echo on

:: This program will manually install the necessary drivers
:: to activate the Sound Card and CDROM.
:: It will update the system files accordingly.

:: It will also uninstall itself with the "uninstall" option

:: if invoked as 'manual', show syntax
:: if invoked as 'a:manual' or '..\manual', demand cd to us

	if "%1" == ""				goto syntax
	if not exist manual.bat			goto baddrive

:: if invoked as 'manual', show syntax
:: if invoked as 'manual trgdir', skip windows parse


:INSTALL

:: if trgdir does not exist as a directory, go to make it
:: otherwise, offer a break, and go to copy files if continue.
:: if necessary, create the directory and error if failed
:: call the external "COPY DOS FILES" program, mancopy.bat
:: if have windir, then call the external "COPY WIN FILES", mancopw.bat

	if not exist %1\nul			goto mkinstalldir
	 echo Warning: the directory '%1' exists.
	 echo Press CONTROL-C to stop this program.
	 pause
	 goto copyfiles

 :mkinstalldir
	mkdir %1
	if not exist %1\nul			goto badinstalldir

  :copyfiles
	:: copy dos minimal set
	 CALL MANCOPY.BAT %1 
	 goto findconfigs


:FINDCONFIGS
:: find the DOS and Windows configuration files, error if failed
:: goto the CONFIG or UNCONFIG for 'install' or 'uninstall'.

	set bootdrive=
	if exist f:\config.sys if exist f:\autoexec.bat	set bootdrive=F:
	if exist e:\config.sys if exist e:\autoexec.bat	set bootdrive=E:
	if exist d:\config.sys if exist d:\autoexec.bat	set bootdrive=D:
	if exist c:\config.sys if exist c:\autoexec.bat	set bootdrive=C:
	if "%bootdrive%" == ""			goto nobootdrive

:CONFIG
	:: update dos config.sys and autoexec.bat
	CALL MANSEDD.BAT %1
	goto doneconfig


:doneconfig
	echo The software has been copied and the system files updated.
	echo CONFIG.SYS and AUTOEXEC.BAT were updated, the previous versions
	echo were saved as CONFIG.### and AUTOEXEC.### (### from 000 to 999),
	echo the largest ### indicating the most recent version.
	goto quit

:syntax
	echo Syntax: manual targetdir 
	echo This program will manually copy the files into 'targetdir', and
	echo will then automatically update CONFIG.SYS and AUTOEXEC.BAT (after
	echo saving the previous versions of these files).
	echo 'device=targetdir\pa3d.sys A220 D1 I7 H7 M320 Q2'
	echo 'device=targetdir\midi406a.sys /IO=230'
	echo 'device=targetdir\cdrom.sys /D:MVCD001'
	echo         AUTOEXEC.BAT
	echo 'targetdir\mscdex.exe /d:mvcd001 /m:10 /v'
	echo 'set blaster=a220 d1 i7 H7 T4'
	echo CONFIG.SYS saved as CONFIG.000 through CONFIG.999.
	echo AUTOEXEC.BAT saved as AUTOEXEC.000 through AUTOEXEC.999.
	goto quit

:baddrive
	echo This program should be started from the drive on which it resides.
	echo The syntax: 'a:manual' or 'b:manual' should be replaced with switching
	echo to the drive and then running the program, like:
	echo          C:\DOS> a:
	echo          A:\SUBDIR> cd \
	echo          A:\> manual targetdir 
	echo Example: A:\> manual c:\medvsn
	goto quit

:badinstalldir
	echo Error: unable to create the directory '%1'.
	goto quit

:nobootdrive
	echo Error: unable to locate boot drive!
	echo This drive must have both CONFIG.SYS and AUTOEXEC.BAT at the top.
	goto quit

:quit
	set bootdrive=
	

	
	
