clear

echo The install program will now copy 
echo Lode Runner to your hard drive.
echo Approximate hard drive space required:  15 Megs
echo
echo Do you wish to (C)ontinue or (E)xit?
pick ce Continue Exit

:Continue
clear
%1:
godir %4 CantCreate

md audio > nul

exists %2:RESOURCE.000 Please insert the disk labeled "Disk 1" in drive %2:.
echo Copying Game files...

copy %2:*.*           
echo %3 > resource.cfg

clear
echo 
echo When the files are finished copying, install will ask
echo you to select your sound and music device.  After this
echo is done, install will attempt to locate your VESA
echo driver so that the game will run in 256 colors.  If it
echo cannot find the correct VESA driver, you will have to
echo install it manually before you run the game.  See the
echo README file for further details.
echo 
echo Processing %2:resource.000...
unchunk RESOURCE.000 . > nul
if ERRORLEVEL 1 goto BadChunk
del RESOURCE.000

exists %2:RESOURCE.001 Please insert the disk labeled "Disk 2" in drive %2:.
copy %2:RESOURCE.001 
echo Processing %2:resource.001...
unchunk RESOURCE.001 . > nul
if ERRORLEVEL 1 goto BadChunk
del RESOURCE.001

exists %2:RESOURCE.002 Please insert the disk labeled "Disk 3" in drive %2:.
copy %2:RESOURCE.002 
echo Processing %2:resource.002...
unchunk RESOURCE.002 . > nul
if ERRORLEVEL 1 goto BadChunk
del RESOURCE.002

exists %2:RESOURCE.003 Please insert the disk labeled "Disk 4" in drive %2:.
copy %2:RESOURCE.003 
echo Processing %2:resource.003...
unchunk RESOURCE.003 . > nul
if ERRORLEVEL 1 goto BadChunk
del RESOURCE.003

exists %2:RESOURCE.004 Please insert the disk labeled "Disk 5" in drive %2:.
copy %2:RESOURCE.004 
echo Processing %2:resource.004...
unchunk RESOURCE.004 . > nul
if ERRORLEVEL 1 goto BadChunk
del RESOURCE.004

del UNCHUNK.EXE

setsound

if NOT exist prsadd.exe goto MIDI_ADDED

clear
echo     
echo      Please select a type of MIDI device.
echo      If you don't know, select FM MIDI
echo     
echo         f.  FM MIDI device
echo         g.  General MIDI device
echo
echo     
echo            Please press f or g.
pick fg FM_MIDI GENERAL_MIDI

:FM_MIDI
if NOT exist prsadd.exe goto MIDI_ADDED
echo @echo Processing files, one moment please... > add.bat
echo @prsadd lr256.prs fm.prs >> add.bat
echo @prsadd lr16.prs fm.prs >> add.bat
echo @prsadd lr256.prs sound.prs >> add.bat
echo @del prsadd.exe >> add.bat
echo @del fm.prs >> add.bat
echo @del genmid.prs >> add.bat
echo @del sound.prs >> add.bat
add
del add.bat
goto MIDI_ADDED

:GENERAL_MIDI
if NOT exist prsadd.exe goto MIDI_ADDED
echo @echo Processing files, one mement please... > add.bat
echo @prsadd lr256.prs genmid.prs >> add.bat
echo @prsadd lr16.prs genmid.prs >> add.bat
echo @prsadd lr256.prs sound.prs >> add.bat
echo @del prsadd.exe >> add.bat
echo @del fm.prs >> add.bat
echo @del genmid.prs >> add.bat
echo @del sound.prs >> add.bat
add
del add.bat
goto MIDI_ADDED

:MIDI_ADDED

echo @%2: > out.bat
echo @cd vesa >> out.bat
echo @vesainst /Vvesa /B%1:%4 /T%1:%4\SIERRA.DIB >> out.bat
echo @cd \ >> out.bat
echo @%1: >> out.bat
out
del out.bat

echo @%1: > %4\..\lr.bat
echo @cd %4 >> %4\..\lr.bat
echo @if exist vesadrv.bat call vesadrv.bat >> %4\..\lr.bat
echo @loderunn >> %4\..\lr.bat

echo @%1: > %4\lr.bat
echo @cd %4 >> %4\lr.bat
echo @if exist vesadrv.bat call vesadrv.bat >> %4\lr.bat
echo @loderunn >> %4\lr.bat

clear
echo
echo ˙To play NOW:
echo ˙   Type LR and press [ENTER].
echo
echo ˙To play LATER:
echo ˙   From the root directory of %1:
echo ˙   Type CD %4 and press [ENTER], then
echo ˙   Type LR and press [ENTER].
echo
pause
end

:NoSpace
clear
echo
alert There is not enough space on %1: to install Lode Runner on your hard drive.  11 megabytes of disk space are necessary.
end

:CantCreate
clear
echo
alert Unable to create directory %4
end

:Corrupted
alert Corrupted files exist.  Please run install again.
end

:BadChunk
if ERRORLEVEL 6 goto ERR6
if ERRORLEVEL 5 goto ERR5
if ERRORLEVEL 4 goto ERR4
if ERRORLEVEL 3 goto ERR3
if ERRORLEVEL 2 goto ERR2
if ERRORLEVEL 1 goto ERR1
alert Unable to extract resource file.  Please run install again.
end

:ERR1
alert Unable to read resource file.  Make sure the drive door is shut and run install again.
end
:ERR2
alert Unable to write resource file to hard drive.  This program only installs games on hard drives.  Run install again.  If you get this message again you may have a problem with your hard drive.
end
:ERR3
alert Not enough memory to run extraction program.  The extraction program needs a minimum of 550k to operate.
end
:ERR4
alert The resource file is bad.  Run install again.  If you get this message again, you probably received a bad disk.
end
:ERR5
alert Unable to open the resource file for reading.  A possible solution might be to increase the value of the FILES setting in your CONFIG.SYS file.
end
:ERR6
alert Unable to open the target file for writing.  A possible solution might be to increase the value of the FILES setting in your CONFIG.SYS file.
end

:exit
end
