@rem 4DOS MOUNT utility for disk file images on TDSK devices.
@echo off
if %1.==. goto ayuda
if %@search[ems.com].==. goto falta_emscom
if %@search[tdsk.exe].==. goto falta_tdskexe
tdsk /m %2 0 > nul
set tamdsk=%@int[%@eval[%@filesize[%1]/1024]]
set tdsops=/A /M
if %@ems[K] LT %@int[%@eval[%@filesize[%1]/1024]] goto falta_mem
if %tamdsk%==360  goto u360
if %tamdsk%==1200 goto u1200
if %tamdsk%==720  goto u720
if %tamdsk%==1440 goto u1440
if %tamdsk%==820  goto u820
if %tamdsk%==1476 goto u1476
if %tamdsk%==976  goto u976
if %tamdsk%==1804 goto u1804
if %tamdsk%==902  goto u902
if %tamdsk%==1558 goto u1558
if %tamdsk%==1148 goto u1148
if %tamdsk%==1640 goto u1640
if %tamdsk%==1680 goto u1680
if %tamdsk%==1722 goto u1722
if %tamdsk%==1886 goto u1886
echo ÿ
echo Filename %1 doesn't exist or is not a raw disk file image (RAWCOPY).
goto fin_err

:u360
tdsk %tdsops% %2 360 0 112 2 /f:2 /e > nul
goto malloc

:u1200
tdsk %tdsops% %2 1200 0 224 /f:2 > nul
goto malloc

:u720
tdsk %tdsops% %2 720 0 112 2 /f:2 > nul
goto malloc

:u1440
tdsk %tdsops% %2 1440 0 224 /f:2 > nul
goto malloc

:u820
tdsk %tdsops% %2 820 0 176 /f:2 > nul
goto malloc

:u1476
tdsk %tdsops% %2 1476 0 224 /f:2 > nul
goto malloc

:u976
tdsk %tdsops% %2 976 0 192 /f:2 > nul
goto malloc

:u1804
tdsk %tdsops% %2 1804 0 224 /f:2 > nul
goto malloc

:u902
tdsk %tdsops% %2 902 0 176 /f:2 > nul
goto malloc

:u1558
tdsk %tdsops% %2 1558 0 224 /f:2 > nul
goto malloc

:u1148
tdsk %tdsops% %2 1148 0 192 /f:2 > nul
goto malloc

:u1640
tdsk %tdsops% %2 1640 0 224 /f:2 > nul
goto malloc

:u1680
tdsk %tdsops% %2 1680 0 16 4 /f:2 > nul
goto malloc

:u1722
tdsk %tdsops% %2 1722 0 224 /f:2 > nul
goto malloc

:u1886
tdsk %tdsops% %2 1886 0 224 /f:2 > nul
goto malloc

:malloc
if errorlevel==255 goto tdsk_noins
if errorlevel==254 goto mal_disco
if errorlevel==253 goto en_windows
if errorlevel==252 goto sintax_err
echo ÿ
echos Mounting %tamdsk%K file...
for %%a in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) do (
  if errorlevel==%%a ems load %%a %1 )
echo %@char[13]File mounted in TURBODSK %tamdsk% Kb EMS drive %2
goto fin

:falta_emscom
echo ÿ
echo EMS.COM utility from QEMM not found in path.
goto fin_err

:falta_tdskexe
echo ÿ
echo TDSK.EXE not found in path.
goto fin_err

:falta_mem
echo ÿ
echo Insufficient memory to mount the requested file.
goto fin

:tdsk_noins
echo ÿ
echo TURBODSK 2.3 is not loaded in memory.
goto fin_err

:mal_disco
echo ÿ
echo Drive letter indicated is not a TURBODSK 2.3 device.
goto fin_err

:en_windows
echo ÿ
echo Inside WINDOWS it is not possible to modify a TURBODSK drive.
echo So, it is not possible to mount inside Windows environ.
goto fin

:sintax_err
echo ÿ
echo Syntax error.
goto fin_err

:fin_err
echo Run MOUNT without parameters to obtain help.
goto fin

:ayuda
cls
echo ÿ
echo          TDMOUNT 2.3 - Utility to mount disk file images in TDSK drives.
echo       (C) 1993-1995 Ciriaco Garc¡a de Celis - ciri@gui.uva.es - 2:341/21.8
echo ÿ
echo     - This BTM utility for 4DOS allows to ®mount¯ disk file images, created
echo       by David Astruga DCOPY (and many other disk copy tools),  RAWRITE  or
echo       DISKCOPY from DR-DOS/Novell DOS, onto a TDSK drive using EMS memory.
echo ÿ
echo     - There are supported standard disks (360K, 1.2M, 720K, 1.44M) and most
echo       2M disks (3«: 976/1066/1148K, 1804/1886K;  5¬: 820/902K, 1476/1558K),
echo       some FDFORMAT ones (820K/1640K/1722K) & Microsoft DMF disks (1.68M).
echo ÿ
echo     - This program requires to have QEMM loaded and EMS.COM (a utility from
echo       QEMM) and TDSK.EXE files in the system PATH (and also, sufficient EMS
echo       memory free), and 4DOS. Sorry for the ®high¯ configuration needed.
echo ÿ
echo     - Syntax:  TDMOUNT fileimage [U:]
echo ÿ
echo        (U: is optional; it will be used the first TDSK device by default).
echo ÿ

:fin
set tamdsk=
set tdsops=
