0% found this document useful (0 votes)
100 views5 pages

Dreamcast Iso Fix Batch File

This document contains batch script code for converting a CDI image file to a self-booting game folder format called "Data-Data" that can be burned to a CD. The script extracts the contents of the CDI to a folder, modifies binary files to make them self-booting, and cleans up files. It then provides options to manually modify the folder contents before creating a new bootable ISO and CDI image from the folder.

Uploaded by

Gary Newman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views5 pages

Dreamcast Iso Fix Batch File

This document contains batch script code for converting a CDI image file to a self-booting game folder format called "Data-Data" that can be burned to a CD. The script extracts the contents of the CDI to a folder, modifies binary files to make them self-booting, and cleans up files. It then provides options to manually modify the folder contents before creating a new bootable ISO and CDI image from the folder.

Uploaded by

Gary Newman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

if !bootMenu!==!dp3BootMenu!

(
echo. >> %workDirMulti%/DP3.ini
echo [Game_ID] >> %workDirMulti%/DP3.ini
echo. >> %workDirMulti%/DP3.ini
echo XGame_ID='610-9999' >> %workDirMulti%/DP3.ini
echo XGame_Ver='V0.999' >> %workDirMulti%/DP3.ini

::finalize DPWWW/INDEX.HTM file


echo ^</center^>^</div^>^</body^>^</html^> >> !workDirMulti!/DPWWW/INDEX.HTM
)

set volumeName=%compilationFolder%
set gameName=%parseGameNameResult%
set gameFolder=%gameWorkingDir%
set extractedFolder=%compilationFolder%

exit /b

:parse_game_name
set internal_val=%~1
call :parse_game_name_internal %internal_val: =_%
set parseGameNameResult=!parseGameNameResult!!val!
set "val=_"
exit /b

:parse_game_name_internal
for /f "tokens=1* delims=_-:;," %%i in ("%~1") do (
set val=%%i
set val=!val:~0,1!
set parseGameNameResult=%parseGameNameResult%%val%
call :parse_game_name_internal %%j
)

exit /b

:cdi_to_data_data_folder
set filename=%1
set /a shouldCreateCDI=%2
set initialFileFormat=Audio-Data
if "%shouldCreateCDI%"=="" set shouldCreateCDI=1

set gameName=not set


for %%i in (%filename%) do (
set gameName=%%~ni
set gameFileName=%%~nxi
set gameFilePath=%%~dpi
)

set gameName=%gameName: =_%

echo Selected Game Name is %gameName%

set gameFolder="%gameWorkingDir%\%gameName%"

mkdir %gameFolder%

cd %gameFolder%

set launchDir=%~dp0
set workDir=%cd%
echo workDir=%workDir%

"%launchDir%"\cdirip %filename% "%workDir%"

::reading LBA value for game data file


"%launchDir%"\cdirip %filename% -info>cdiripinfo.log
for /f "tokens=8 delims= " %%i in ('FINDSTR /C:"LBA" "%workDir%"\cdiripinfo.log') do set "lba=%%i"

::reading track number for game data file


type "%workDir%"\cdiripinfo.log | find /c "LBA">"%workDir%"\track_number.log
set /p trackNumber=< "%workDir%"\track_number.log
if "%keepFiles%"=="false" del "%workDir%"\track_number.log
if "%keepFiles%"=="false" del cdiripinfo.log
::add leading zero if needed
if 1%trackNumber% LSS 100 SET trackNumber=0%trackNumber%
set trackNumber=%trackNumber:~-2%

set sessionNumber=02
if "%trackNumber%"=="01" set sessionNumber=01
set isoFileName=s%sessionNumber%t%trackNumber:~-2%.iso
echo lba=%lba%
echo isoFileName=%isoFileName%

set archiveForExtraction=fixed.iso
::if not exist fixed.iso if exist s01t01.bin set archiveForExtraction=s01t01.bin

if not exist *.iso if exist *.bin (


echo.
echo %gameFileName% is already in Data-Data format.
echo Image in Audio-Data format expected.
echo You can use %gameFileName% directly to burn it to CD-R.
echo No processing for this file is required.
echo.
set initialFileFormat=Data-Data
cd \..
call :delete_folder '%gameFolder%' >nul
::rd /s /q %gameFolder% >nul
::del /f /q *.*
::exit from function
goto :cdi_to_data_data_folder_end
)

::fix image so it's possible to extract it's content


(
echo %isoFileName%
echo %lba%
)|"%launchDir%\isofix"

if not exist !archiveForExtraction! set archiveForExtraction=!isoFileName!

::extracting iso content


set extractedFolder=%gameName%
echo Extracting %archiveForExtraction% to plain folder... Please wait...
"%launchDir%\7z" x -y -o%extractedFolder% %archiveForExtraction%
::"%launchDir%\piso" extract %archiveForExtraction% / -od %extractedFolder%

::delete unnecessary files


if "%keepFiles%"=="false" (
del %isoFileName%
del *.wav
del *.cue
del %archiveForExtraction%
del header.iso
)

::set /p WAIT=Extracted. Press ENTER...

set bootFile=""

if exist %extractedFolder%\0.000 set bootFile=0.000


if exist %extractedFolder%\1ST_READ.BIN set bootFile=1ST_READ.BIN
if exist %extractedFolder%\0WINCEOS.BIN set bootFile=0WINCEOS.BIN
if exist %extractedFolder%\1GUTH.BIN set bootFile=1GUTH.BIN

if %bootFile%=="" (
echo Can't locate boot file ^(1ST_READ.BIN or 0WINCEOS.BIN^). Please pick boot file manually
call :pick_dialog -filter "All Files (*.*)|*.*" -title "Pick boot file (equivalent of 1ST_READ.BIN or
0WINCEOS.BIN)"
for %%i in (!fileNameList!) do set "bootFile=%%~nxi"
)

set bootSector=IP.BIN
echo bootFile="%bootFile%"

if not exist bootfile.bin copy %extractedFolder%\IP.BIN


ren bootfile.bin %bootSector%
move %extractedFolder%\%bootFile% ".\" >nul

::hack all possible bin files


echo Hacking all possible BIN files...
for /f "tokens=1* delims=\" %%A in (
'forfiles /p %extractedFolder% /s /m *.BIN /c "cmd /c echo @relpath"'
) do for %%F in (^"%%B) do (
set fileName=%%~F
(
echo .\%extractedFolder%\%%~F
echo IP.BIN
echo 0
)|"%launchDir%\binhack32" >nul
)

::hack main file


echo Hacking main file...
(
echo %bootFile%
echo %bootSector%
echo 0
)|"%launchDir%\binhack32"

move %bootFile% %extractedFolder% >nul


move IP.BIN %extractedFolder% >nul

echo Convertation to self booting folder for %gameName% finished


:cdi_to_data_data_folder_end

cd %launchDir%
exit /b
:bootable_cdi_from_folder
echo.
echo Creating CDI data-data file...
cd %gameFolder%
set volumeName=%gameName:~0,32%
echo volumeName=%volumeName%
if "%manualModification%"=="enabled" (
set /p WAIT=It's time to modify selfboot folder's content. When Ready press ENTER to proceed with creation
of CDI image...
)
echo.
echo Creating bootable ISO from folder...
"%launchDir%\mkisofs" -C 0,0 -G %extractedFolder%\IP.BIN -V %volumeName% -joliet -rock -l -o data.iso
%extractedFolder% >nul
call :delete_folder %extractedFolder% > nul
echo.
echo Creating CDI from ISO... Please Wait...
"%launchDir%\cdi4dc" data.iso %gameName%.cdi -d >nul
echo Creation of %gameName%.cdi is finished.
echo Full path to CDI image is %cd%\%gameName%.cdi

::delete unnecessary files


if "%keepFiles%"=="false" del data.iso

cd %launchDir%
exit /b

:delete_folder
if "%keepFiles%"=="false" (
set folderToDelete=%~1
set folderToDelete=!folderToDelete:"=!
set folderToDelete=!folderToDelete:'=!
echo Deleting folder !folderToDelete!
del /s /f /q "!folderToDelete!" >nul
for /f %%f in ('dir /ad /b "!folderToDelete!"') do rd /s /q "!folderToDelete!"\%%f >nul
rd /s /q "!folderToDelete!" >nul
)
exit /b

You might also like