Added silent flag to mkpsxixo
This commit is contained in:
parent
aad614833a
commit
6b14cee120
108
tools/mkpsxiso.c
108
tools/mkpsxiso.c
|
@ -7,11 +7,21 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef bool
|
||||
typedef enum t_bool
|
||||
{
|
||||
false = 0,
|
||||
true = 1
|
||||
}bool;
|
||||
|
||||
#endif // bool
|
||||
|
||||
char iso2raw_sec[16];
|
||||
char iso2raw_sub[8];
|
||||
char iso2raw_buf[2048];
|
||||
char iso2raw_edc[4];
|
||||
char iso2raw_ecc[276];
|
||||
bool silent_flag;
|
||||
|
||||
void Iso2Raw_init()
|
||||
{
|
||||
|
@ -206,11 +216,18 @@ int Iso2Raw_convert(char *isofile, char *rawfile, char *licfile)
|
|||
|
||||
iso2raw_sec[14] = ((thesec/10)<<4)|(thesec - ((thesec/10)*10));
|
||||
|
||||
if (silent_flag == false)
|
||||
{
|
||||
printf("\r%d%% completed...", sector * 100 / totalsectors);
|
||||
}
|
||||
|
||||
sector++;
|
||||
}
|
||||
|
||||
if (silent_flag == false)
|
||||
{
|
||||
printf("\r100%% completed! \n");
|
||||
}
|
||||
|
||||
fclose(infile);
|
||||
fclose(outfile);
|
||||
|
@ -223,18 +240,92 @@ int Iso2Raw_convert(char *isofile, char *rawfile, char *licfile)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int AddMusicTracksToCue(int track_n, char * bin_file, int bin_name_length, char * track)
|
||||
{
|
||||
char * track_tokens = strtok(track,"=");
|
||||
char * aux_tokens;
|
||||
char * file_name;
|
||||
FILE * out_file;
|
||||
FILE * track_file;
|
||||
|
||||
if (strncmp(track_tokens,"--track",strlen("--track") ) != 0)
|
||||
{
|
||||
printf("Incorrect %s parameter!\n",track_tokens);
|
||||
return 1;
|
||||
}
|
||||
|
||||
track_tokens = strtok(NULL,"=");
|
||||
|
||||
bin_file[bin_name_length - 3] = 'c';
|
||||
bin_file[bin_name_length - 2] = 'u';
|
||||
bin_file[bin_name_length - 1] = 'e';
|
||||
|
||||
out_file = fopen(bin_file,"a+");
|
||||
|
||||
if (out_file == NULL)
|
||||
{
|
||||
printf("Error opening %s .\n",bin_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
track_file = fopen(track_tokens,"r");
|
||||
|
||||
if (track_file == NULL)
|
||||
{
|
||||
printf("Could not open track %s!\n",track_tokens);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose(track_file);
|
||||
|
||||
aux_tokens = strtok(track_tokens,"\\/");
|
||||
|
||||
while(aux_tokens != NULL)
|
||||
{
|
||||
file_name = aux_tokens;
|
||||
aux_tokens = strtok(NULL,"\\/");
|
||||
}
|
||||
|
||||
fprintf(out_file, "FILE \"%s\" BINARY\n", file_name);
|
||||
fprintf(out_file, "TRACK %.02d AUDIO\n",track_n);
|
||||
fprintf(out_file, "\tINDEX 00 00:00:00\n");
|
||||
fprintf(out_file, "\tINDEX 01 00:02:00\n");
|
||||
|
||||
printf("Track %s added.\n",file_name);
|
||||
|
||||
fclose(out_file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void showHelp(void)
|
||||
{
|
||||
puts("mkpsxiso (C Edition) v0.1b - Converts a standard ISO image to .bin/.cue (PSX)");
|
||||
puts("Usage: mkpsxiso <iso file> <bin file> <PSX license file> [-s] [--track=path1] ... [--track=pathn]\n");
|
||||
puts("This software is based on Bruno Freitas' mkpsxiso in Java - bootsector@ig.com.br");
|
||||
puts("That version is in turn based on Conyers' mkpsxiso - http://www.conyers.demon.co.uk");
|
||||
puts("Author: Giuseppe Gatta (aka nextvolume) - 01/07/2009 - tails92@gmail.com\n");
|
||||
puts("Music track modifications by Xavier Del Campo (aka Xavi92) - 14/10/2016 - xavi.dcr@gmail.com\n");
|
||||
}
|
||||
|
||||
if(argc != 4)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Usage: mkpsxiso <iso file> <bin file> <PSX license file>\n");
|
||||
int track_n = 2;
|
||||
int i = 4;
|
||||
|
||||
if (argc < 4)
|
||||
{
|
||||
showHelp();
|
||||
return 1;
|
||||
}
|
||||
else if (argc > 4)
|
||||
{
|
||||
if (strcmp(argv[i], "-s") == 0)
|
||||
{
|
||||
silent_flag = true;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Iso2Raw_init();
|
||||
|
||||
|
@ -244,7 +335,16 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
puts("ISO file conversion terminated successfully!!");
|
||||
for (; i < argc; i++)
|
||||
{
|
||||
if (AddMusicTracksToCue(track_n, argv[2], strlen(argv[2]), argv[i]) != 0)
|
||||
{
|
||||
// Errors are already reported by AddMusicTracksToCue().
|
||||
return 1;
|
||||
}
|
||||
|
||||
track_n++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue