@@ -29,27 +29,29 @@ static void PrintHelp()
2929 Console . WriteLine ( "" ) ;
3030 Console . WriteLine ( "Rebuild mode: Don't use any options (combines input files)" ) ;
3131 Console . WriteLine ( "Extract mode: Use one or more options (splits input file)" ) ;
32- Console . WriteLine ( "-a, --all \t Perform all operations (-rstuvwxy) on the input ISO, except --zar" ) ;
33- Console . WriteLine ( "-q, --quiet \t Don't print INFO messages to console" ) ;
34- Console . WriteLine ( "-r, --random\t Extracts random filler data to a separate file" ) ;
35- Console . WriteLine ( "-s, --seed \t Extracts RNG seed used for XGD1 filler" ) ;
36- Console . WriteLine ( "-t, --trim \t Trims end of XISO (game partition)" ) ;
37- Console . WriteLine ( "-u, --update\t Extracts update file from video ISO (XGD3 only)" ) ;
38- Console . WriteLine ( "-v, --video \t Extracts video ISO (video partition)" ) ;
39- Console . WriteLine ( "-w, --wipe \t Wipes random filler data in XISO" ) ;
40- Console . WriteLine ( "-x, --xiso \t Extracts XDVDFS ISO (game partition)" ) ;
41- Console . WriteLine ( "-y, --skelly\t Extracts XDVDFS skeleton (game partition with zeroed files)" ) ;
42- Console . WriteLine ( "-z, --zar \t Converts XISO to zar (zstd compressed archive of game files)" ) ;
32+ Console . WriteLine ( "-a, --all \t Perform all operations (-prstuvwxy) on the input ISO, except --zar" ) ;
33+ Console . WriteLine ( "-p, --petrify\t Extracts XDVDFS skeleton (game partition with zeroed files)" ) ;
34+ Console . WriteLine ( "-q, --quiet \t Don't print INFO messages to console" ) ;
35+ Console . WriteLine ( "-r, --random \t Extracts random filler data to a separate file" ) ;
36+ Console . WriteLine ( "-s, --seed \t Extracts RNG seed used for XGD1 filler" ) ;
37+ Console . WriteLine ( "-t, --trim \t Trims end of XISO (game partition)" ) ;
38+ Console . WriteLine ( "-u, --update \t Extracts update file from video ISO (XGD3 only)" ) ;
39+ Console . WriteLine ( "-v, --video \t Extracts video ISO (video partition)" ) ;
40+ Console . WriteLine ( "-w, --wipe \t Wipes random filler data in XISO" ) ;
41+ Console . WriteLine ( "-x, --xiso \t Extracts XDVDFS ISO (game partition)" ) ;
42+ Console . WriteLine ( "-y, --yes \t Assume yes for all interactive prompts (skips warnings)" ) ;
43+ Console . WriteLine ( "-z, --zar \t Converts XISO to zar (zstd compressed archive of game files)" ) ;
4344 }
4445
4546 static void Main ( string [ ] args )
4647 {
4748 #region Initial Setup
4849
49- // Initialize VIDEO_LENGTH array
50+ // Initialize VIDEO_LENGTH array at run-time
5051 for ( int i = 0 ; i < VIDEO_LENGTH . Length ; i ++ )
5152 VIDEO_LENGTH [ i ] = VIDEO_L0_LENGTH [ i ] + VIDEO_L1_LENGTH [ i ] ;
5253
54+ // Initialize program options
5355 bool help = false ;
5456 bool quiet = false ;
5557 bool extractXISO = false ;
@@ -210,7 +212,7 @@ static void Main(string[] args)
210212 updatePath = filePaths [ 3 ] ;
211213
212214 // Determine input filenames
213- // TODO: Account for 1st input file being .video.iso or .redump.iso
215+ // TODO: Account for 1st input file being .video.iso or .redump.iso or .xiso.skeleton.zstd
214216 string dir = Path . GetDirectoryName ( isoPath ) ;
215217 string filename = Path . GetFileNameWithoutExtension ( isoPath ) ;
216218 string extension = Path . GetExtension ( isoPath ) ;
@@ -236,7 +238,7 @@ static void Main(string[] args)
236238 if ( string . IsNullOrEmpty ( zarPath ) )
237239 zarPath = Path . Combine ( dir , $ "{ filename } .zar") ;
238240 string xisoPath = Path . Combine ( dir , $ "{ filename } .xiso") ;
239- // TODO: Prefer just .iso if it doesn't already exist
241+ // TODO: Prefer just .iso if it doesn't already exist?
240242 string redumpPath = Path . Combine ( dir , $ "{ filename } .redump.iso") ;
241243
242244 // Compare input ISO file size to determine file type
@@ -679,36 +681,39 @@ static void Main(string[] args)
679681 #region Mode 2: Video ISO as input
680682
681683 // Check for valid options
684+ bool invalidOptions = false ;
682685 if ( extractVideo )
683686 {
684- Console . WriteLine ( "[ERROR] Cannot extract video (-v), input file is already video." ) ;
685- return ;
687+ Console . WriteLine ( "[ERROR] Cannot extract video (-v), input file is already video ISO ." ) ;
688+ invalidOptions = true ;
686689 }
687690 if ( extractXISO )
688691 {
689- Console . WriteLine ( "[ERROR] Cannot extract XISO (-x), input file is video." ) ;
690- return ;
692+ Console . WriteLine ( "[ERROR] Cannot extract XISO (-x), input file is video ISO ." ) ;
693+ invalidOptions = true ;
691694 }
692695 if ( extractFiller )
693696 {
694- Console . WriteLine ( "[ERROR] Cannot extract filler (-s), input file is video." ) ;
695- return ;
697+ Console . WriteLine ( "[ERROR] Cannot extract filler (-s), input file is video ISO ." ) ;
698+ invalidOptions = true ;
696699 }
697700 if ( wipeXISO )
698701 {
699- Console . WriteLine ( "[ERROR] Cannot wipe XISO (-w), input file is video." ) ;
700- return ;
702+ Console . WriteLine ( "[ERROR] Cannot wipe XISO (-w), input file is video ISO ." ) ;
703+ invalidOptions = true ;
701704 }
702705 if ( trimXISO )
703706 {
704- Console . WriteLine ( "[ERROR] Cannot trim XISO (-t), input file is video." ) ;
705- return ;
707+ Console . WriteLine ( "[ERROR] Cannot trim XISO (-t), input file is video ISO ." ) ;
708+ invalidOptions = true ;
706709 }
707710 if ( ! extractUpdate )
708711 {
709712 Console . WriteLine ( "[ERROR] Use -u flag to extract system update from video partition." ) ;
710- return ;
713+ invalidOptions = true ;
711714 }
715+ if ( invalidOptions )
716+ return ;
712717
713718 // Check that update file doesn't already exist
714719 if ( File . Exists ( updatePath ) )
@@ -724,7 +729,7 @@ static void Main(string[] args)
724729 return ;
725730 }
726731
727- // Open ISO for reading and writing
732+ // Open video ISO for reading and writing
728733 using FileStream videoFS = new ( isoPath , FileMode . Open , FileAccess . ReadWrite , FileShare . None ) ;
729734 long updateOffset = XDVDFS . SUOffset ( videoFS ) ;
730735
@@ -755,22 +760,23 @@ static void Main(string[] args)
755760 bool invalidOptions = false ;
756761 if ( extractXISO )
757762 {
758- Console . WriteLine ( "[ERROR] Cannot extract XISO (-x), input file is already XISO" ) ;
763+ Console . WriteLine ( "[ERROR] Cannot extract XISO (-x), input file is already XISO. " ) ;
759764 invalidOptions = true ;
760765 }
761766 if ( extractVideo )
762767 {
763- Console . WriteLine ( "[ERROR] Cannot extract video (-v), input file is XISO" ) ;
768+ Console . WriteLine ( "[ERROR] Cannot extract video (-v), input file is XISO. " ) ;
764769 invalidOptions = true ;
765770 }
766771 if ( extractUpdate )
767772 {
768- Console . WriteLine ( "[ERROR] Cannot extract update (-u), input file is XISO" ) ;
773+ Console . WriteLine ( "[ERROR] Cannot extract update (-u), input file is XISO. " ) ;
769774 invalidOptions = true ;
770775 }
771776 if ( invalidOptions )
772777 return ;
773778
779+ // Open XISO for reading
774780 using FileStream isoFS = new ( isoPath , FileMode . Open , FileAccess . Read , FileShare . Read ) ;
775781 if ( ! quiet )
776782 Console . WriteLine ( $ "[INFO] Reading XISO from { isoPath } ") ;
@@ -1031,6 +1037,7 @@ static void Main(string[] args)
10311037 if ( ! File . Exists ( fillerPath ) && ! File . Exists ( seedPath ) )
10321038 {
10331039 // No filler data or seed available, write entire XISO
1040+ // TODO: Warn or error if filler is zeroed in XISO
10341041 if ( ! Utils . WriteBytes ( isoFS , redumpFS , - 1 , isoSize ) )
10351042 {
10361043 Console . WriteLine ( $ "[ERROR] Failed writing game partition: { isoSize } ") ;
0 commit comments