@echo off
cycles max
iscrc32 floppy\resource.map 5D4B90B8
if errorlevel 1 goto failFloppy
iscrc32 floppy\resource.000 98A8B567
if errorlevel 1 goto failFloppy
iscrc32 floppy\resource.001 4FA64AF6
if errorlevel 1 goto failFloppy
iscrc32 floppy\resource.002 CC00BF29
if errorlevel 1 goto failFloppy
iscrc32 floppy\resource.003 C2C8D533
if errorlevel 1 goto failFloppy
iscrc32 floppy\resource.004 48224583
if errorlevel 1 goto failFloppy
iscrc32 floppy\resource.005 485051EB
if errorlevel 1 goto failFloppy
iscrc32 cdrom\resource.map 1677D9F4
if errorlevel 1 goto failCD
iscrc32 cdrom\resource.000 CE475558
if errorlevel 1 goto failCD

if exist new\*.* del new\*.*
mkdir new
chdir new
echo Extracting from floppy version...
copy ..\floppy\resource.00? > nul
copy ..\floppy\resource.map > nul
..\sciget -newnames pic 0 999 
..\sciget -newnames sound 107 
..\sciget -newnames sound 11
..\sciget -newnames sound 110 
..\sciget -newnames sound 111 
..\sciget -newnames sound 112 
..\sciget -newnames sound 5 
..\sciget -newnames sound 6 
..\sciget -newnames sound 7 
..\sciget -newnames sound 8 
..\sciget -newnames patch 101
del resource.*
echo Extracting from CD-ROM version...
copy ..\cdrom\resource.000 > nul
copy ..\cdrom\resource.map > nul
..\sciget %1 view 0 65535
..\sciget %1 pic 396
..\sciget %1 pic 399
..\sciget %1 pic 570
..\sciget %1 pic 64
..\sciget %1 pic 9900
..\sciget %1 pic 9996
..\sciget %1 script 0 65535
..\sciget %1 text 0 65535
..\sciget %1 sound 0 65535
..\sciget %1 vocab 0 65535
..\sciget %1 font 0 65535
..\sciget %1 patch 0 65535
..\sciget %1 palette 0 65535
..\sciget %1 message 0 65535
..\sciget %1 map 0 65535
..\sciget %1 heap 0 65535
del resource.000
del resource.map
copy ..\cdrom\???.scr > nul
copy ..\cdrom\???.hep > nul
copy ..\cdrom\*.drv > nul
copy ..\cdrom\install.* > nul
copy ..\cdrom\sierra.exe > nul
copy ..\cdrom\interp.err > nul
echo  videoDrv  = VGA320.DRV > RESOURCE.CFG
echo  kbdDrv    = IBMKBD.DRV >> RESOURCE.CFg
echo  audioSize = 16k >> RESOURCE.CFG
echo  minHunk   = 206K >> RESOURCE.CFG
echo  audio     = .\ >> RESOURCE.CFG
copy ..\cdrom\resource.aud > nul
echo Patching...
copy ..\diff\readme > nul
copy ..\diff\version > nul
copy ..\diff\65535.m32 > nul
call ..\diff\dodiff.bat
..\respak11
del *.scr
del *.hep
del *.v56
del *.p56
del *.tex
del *.snd
del *.voc
del *.fon
del *.pat
del *.pal
del *.msg
del ?.map
del ??.map
del ???.map
del 65535.map
..\iscrc32 resource.map 519D88FC
if not errorlevel 1 goto okE
echo Something went wrong during patching:
echo The resulting RESOURCE.MAP file has an incorrect CRC32.
echo Press any key to continue anyway, knowing that the patched game might not work...
pause > nul
:okE
install.exe
goto finish

:failFloppy
echo Floppy version not found or not as expected!
goto usage

:failCD
echo CD-ROM version not found or not as expected!

:usage
echo 1. Extract the patch files into the current directory
echo 2. Copy the files from the English 256-color version 1.052 or 1.1
echo    into a subdirectory FLOPPY\
echo 3. Copy the files from the CD-ROM version into a subdirectory CDROM\
echo 4. Run PATCHSQ4.BAT (this file)
echo 5. The patched game will be in a subdirectory NEW\

:finish
