diff options
| author | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
|---|---|---|
| committer | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
| commit | 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d (patch) | |
| tree | c28d0748652ad4b4222309e46e6cfc82c0906220 /tools/getpsxiso.c | |
| parent | a2b7b6bb1cc2f4a3258b7b2dbc92399d151f864d (diff) | |
| download | psxsdk-7c24e9a9b02b04dcaf9507acb94091ea70a2c02d.tar.gz | |
Imported pristine psxsdk-20190410 from official repo
Diffstat (limited to 'tools/getpsxiso.c')
| -rw-r--r-- | tools/getpsxiso.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/getpsxiso.c b/tools/getpsxiso.c new file mode 100644 index 0000000..76cfc72 --- /dev/null +++ b/tools/getpsxiso.c @@ -0,0 +1,55 @@ +// Converts a bin suitable for burning for the PlayStation +// to an ISO by getting only the 2048 data bytes of each sector +// The reverse of mkpsxiso + +// Written by Giuseppe Gatta, 2010 + +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + FILE *i, *o; + int x, s; + char buf[2352]; + + if (argc < 3) + { + printf("getpsxiso <input> <output>\n"); + return -1; + } + + i = fopen(argv[1], "rb"); + + if(i == NULL) + { + printf("Could not open specified input file.\n"); + return -1; + } + + fseek(i, 0, SEEK_END); + s = ftell(i) / 2352; + fseek(i, 0, SEEK_SET); + + if(s % 2352 == 0) + { + printf("Input file size not a multiplier of 2352.\n"); + printf("Aborting.\n"); + return -1; + } + + o = fopen(argv[2], "wb"); + + for(x = 0; x < s; x++) + { + fread(buf, sizeof(char), 2352, i); + fwrite(buf + 24, sizeof(char), 2048, o); + printf("Sector %d/%d written\r", x+1, s); + } + + printf("\n"); + + fclose(i); + fclose(o); + + return 0; +} |
