diff options
author | Pixel <Pixel> | 2002-09-27 20:35:05 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-09-27 20:35:05 +0000 |
commit | 28806bc90b9555e78944e80e78e90debfa632b4b (patch) | |
tree | 49b9f61d835cc8df55b84e6a243f7c1d6d73b411 | |
parent | bfa5de7eccf4604ff8217f619e9685a09e80d545 (diff) |
?!? Some files were not added?!?
-rw-r--r-- | AUTHOR | 9 | ||||
-rw-r--r-- | FAQ-cd.txt | 27 | ||||
-rwxr-xr-x | Makefile | 8 | ||||
-rw-r--r-- | cd-tool.cpp | 162 | ||||
-rw-r--r-- | lzss-main.cpp | 53 |
5 files changed, 127 insertions, 132 deletions
@@ -1,3 +1,6 @@ -The PSX-Tools Bundle Pack is principaly written by me, Nicolas "Pixel" -Noble. But some tools were derivated from code by Yazoo, who took some -code from cdrdao. +The PSX-Tools Bundle Pack is principaly written by me, Nicolas "Pixel" Noble. +But some of the original tools were derivated from code by Yazoo, who took some +code from cdrdao for the ECC regeneration code. The str and xa decoders, as well +as the linux cd reader are from the psxdev system. The PSX debugger is, of +course, a hack of Pcsx. +
\ No newline at end of file @@ -21,7 +21,7 @@ A: No. Q: Why? Nero's a spreaded software! A: It's a commercial tool. Since I don't use any commercial tool, and that no - free-software generates Nero ISO, it won't be suppored. + free-software generates Nero ISO, it won't be supported. Q: What is this tool/library able to? @@ -42,8 +42,8 @@ A: Maybe. Since it only runs on Win32 platforms, I've never tried it. Q: So, what is the goal of this software? A: To modify (patch) ISO images. Nothing else. And of course I want it free, - opensource, and working on my preffered operating system, Linux. If somebody - can make it working for windows (and I think this is easy to do) I will + opensource, and working on my prefered operating system, Linux. If somebody + can make it working for windows (and I think this is easy to do) it would please me. I can't do it right now since I don't really have the opportunity to build Win32 binaries (apart of cygwin's ones) @@ -114,6 +114,8 @@ A: Firstly, when you have a raw sector, you have to understand its primary form. <-- sync bytes: 12 bytes --><-- localisation: 3 bytes --><-- mode: 1 byte --> The sync bytes are easy: it is always 00 FF FF FF FF FF FF FF FF FF FF 00 + They are supposed to help the CD reader to synchronize enough to be able to + read the sector correctly. The localisation is the sector "position" described in time. For example, the sector 200000 of a CD is at the "time" 44:28:50. The first is the number @@ -137,7 +139,7 @@ uchar from_BCD(uchar x) {return ((x & 15) + ((x & 240) >> 4) * 10));} uchar to_BCD(uchar x) {return ((x / 10) << 4) | (x % 10));} int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} - Last thing: when you look at a BCD packed number, you have to read it in + Last hint: when you look at a BCD packed number, you have to read it in hexadecimal, and then you will see a "decimal" number. So when you count in BCD, you'll have this: 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, etc... You see? You've got a "gap": no 0x0a, @@ -183,8 +185,11 @@ int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} o) 2nd byte: Channel Number (CN) o) 3rd byte: Sub Mode (SM) o) 4st byte: Coding Info (CI) - -) I've *never* seen any SubHeader for a sector containing data with a FN, - CN or CI different from 0, please inform me if you do. + -) The SubHeaders seems to be very important when dealing with STR files, + since it's the only way to distinguish a video sector from an audio + sector. But it seems that it doesn't matter when dealing with normal + files. It might be obvious since the iso9660 format doesn't care about + those bits. But better try to patch them if necessary... -) The Sub Mode byte is a bit field which seems to be described like this: 0: End of Record (EOR) 1: Video @@ -197,8 +202,8 @@ int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} Of course, the PSX has the CDs in MODE 2... So the common files are stored in MODE 2 FORM 1, the STR/XA files are stored in "MODE 2" but - actually they are in MODE 2 FORM 1/2. The MOVCONV tool will in fact produce - files that does contain the subheaders. + actually they are in MODE 2 FORM 1 and 2. The MOVCONV tool will in fact + produce files that does contain the subheaders. Those subheaders are very likely to vary, and seems to be very important for stream processing. Please note that "str" video sectors are considered as @@ -219,7 +224,7 @@ int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} This is to optimize the reading process. Since the cd reader is a 2x cd reader, it *HAS* to read data in full 300KBps. So, if you have a sound free video, the reading process will be faster than the decoding process, - and everything will crash. This is about the same for the audio sectors. + and everything should crash. This is about the same for the audio sectors. The 'leap' sector function of MOVCONV does add blank sectors in order to pad the channels that may have stopped before the others. @@ -235,8 +240,8 @@ int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} The CI byte does contains some flags about the current sector, but I'm yet unable to give a full description of them. I've only got this: for - audio frames, the bit 0 is set when you have stereo sound, and the bit 2 - is set when you have "half frequency", ie 18900Hz instead of 37800Hz. + XA audio sectors, the bit 0 is set when you have stereo sound, and the bit + 2 is set when you have "half frequency", ie 18900Hz instead of 37800Hz. The Video frames are in plain Form 1, and the Audio frames are in plain Form 2. But it _seems_ the Video frames are not checked against ECC/EDC, @@ -1,10 +1,10 @@ #!/usr/bin/make -f CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -Iincludes `sdl-config --cflags` -DHAVE_ZLIB -LDFLAGS=-lz +LDFLAGS=-lz `sdl-config --libs` CXX=g++ -SUBDIRS = psxdev generic lib Xenogears +SUBDIRS = psxdev generic lib Xenogears VP MegamanX5 PcsxSrc TARGET = lzss dlzss cd-tool str-player crypto-search bgrep dte-tool all: subdirs ${TARGET} @@ -19,9 +19,9 @@ dlzss: lzss Makefile ln -fs lzss dlzss yazedc: yazedc-main.o lib/lib.a Makefile - ${CXX} yazedc-main.o lib/lib.a -DMAIN -o yazedc ${LDFLAGS} + ${CXX} yazedc-main.o lib/lib.a -DYAZEDC_MAIN -o yazedc ${LDFLAGS} -cd-tool: includes/cdutils.h includes/generic.h includes/yazedc.h cd-tool.o Makefile +cd-tool: includes/cdutils.h includes/generic.h includes/yazedc.h cd-tool.o lib/lib.a generic/generic.a Makefile ${CXX} cd-tool.o lib/lib.a generic/generic.a -o cd-tool ${LDFLAGS} dte-tool: includes/generic.h includes/dte.h dtemain.o lib/lib.a generic/generic.a Makefile diff --git a/cd-tool.cpp b/cd-tool.cpp index 35e550f..487a05f 100644 --- a/cd-tool.cpp +++ b/cd-tool.cpp @@ -30,6 +30,8 @@ #include "cdreader.h" #include "cdutils.h" #include "generic.h" +#include "Main.h" +#include "cdabstract.h" int lga = 0; struct option long_options[] = { @@ -40,10 +42,24 @@ struct option long_options[] = { {0, 0, NULL, 0 } }; +CODE_BEGINS +public: +Appli() : cdutil(0), iso_r(0), iso_w(0), file(0) {} +virtual ~Appli() { + delete cdutil; + delete iso_r; + delete iso_w; + delete file; +} +private: + +cdutils * cdutil; +Handle * iso_r, * iso_w, * file; + void showhelp(void) { printm(M_BARE, "Usage:\n" -"cd-tool [-m <mode>] [-p <ppf file>] [-f] <isofile> <command> [command args]\n" +"%s [-m <mode>] [-p <ppf file>] [-f] <isofile> <command> [command args]\n" "Where mode can be 1 for MODE 1, 2 for MODE 2, 3 for MODE 2 FORM 1,\n" "4 for MODE 2 FORM 2 and 5 for autodetect, which is the default behaviour.\n" "\n" @@ -55,12 +71,11 @@ void showhelp(void) { " extract <file> <addr> <size> - extract some sectors to <file>\n" " insert-file <file> <path> - insert the file to <path>\n" " insert <file> <addr> - insert some sectors at <addr>\n" -"\n"); +"\n", argv[0]); } -int Main(int argc, char ** argv) { +virtual int startup() throw (GeneralException) { int type = GUESS, c, size, force = 0, sector; - Handle * iso_r, * iso_w = 0; char * ppf = 0, * iso_name = 0, * arg1 = 0, * arg2 = 0, * f; verbosity = M_WARNING; @@ -71,7 +86,7 @@ int Main(int argc, char ** argv) { case 'H': case '?': showhelp(); - exit(0); + throw Exit(0); case 'm': type = atoi(optarg); break; @@ -87,7 +102,7 @@ int Main(int argc, char ** argv) { if (argc == optind) { showhelp(); printm(M_ERROR, "Need an iso filename to work on.\n"); - exit(-1); + throw Exit(-1); } iso_name = argv[optind++]; @@ -95,120 +110,107 @@ int Main(int argc, char ** argv) { if (argc == optind) { showhelp(); printm(M_ERROR, "Need a command to execute.\n"); - exit(-1); + throw Exit(-1); } - iso_r = new Input(iso_name); + iso_r = open_iso(iso_name); - get_iso_infos(iso_r); + cdutil = new cdutils(iso_r); + + if (!cdutil->get_iso_infos()) + throw Exit(-1); if (!strcmp(argv[optind], "infos")) { - show_iso_infos(iso_r); + cdutil->show_iso_infos(); } else if (!strcmp(argv[optind], "path")) { - show_pt_infos(iso_r); + cdutil->show_pt_infos(); } else if (!strcmp(argv[optind], "printdir")) { - struct DirEntry dir; + cdutils::DirEntry dir; optind++; if ((argc - 1) != optind) { showhelp(); printm(M_ERROR, "printdir needs one argument.\n"); - delete iso_r; - exit(-1); + throw Exit(-1); } arg1 = argv[optind]; - dir = find_path(iso_r, f = strdup(arg1)); + dir = cdutil->find_path(f = strdup(arg1)); free(f); if (!dir.R) { printm(M_ERROR, "Path %s was not found on iso.\n", arg1); - delete iso_r; - exit(-1); + throw Exit(-1); } if (!(dir.Flags & 2)) { printm(M_ERROR, "Path %s design a file and not a directory.\n", arg1); - delete iso_r; - exit(-1); + throw Exit(-1); } - show_head_entry(); - show_dir(iso_r, &dir); + cdutil->show_head_entry(); + cdutil->show_dir(&dir); } else if (!strcmp(argv[optind], "extract-file")) { - struct DirEntry dir; - Handle * file; + cdutils::DirEntry dir; optind++; if ((argc - 2) != optind) { showhelp(); printm(M_ERROR, "extract-file needs two arguments.\n"); - delete iso_r; - exit(-1); + throw Exit(-1); } arg1 = argv[optind++]; arg2 = argv[optind++]; file = new Output(arg1); - dir = find_path(iso_r, f = strdup(arg2)); + dir = cdutil->find_path(f = strdup(arg2)); free(f); if (!dir.R) { printm(M_ERROR, "Path %s was not found on iso.\n", arg2); - delete iso_r; - delete file; - exit(-1); + throw Exit(-1); } printm(M_STATUS, "Reading path %s to file %s.\n", arg2, arg1); - read_file(iso_r, file, type, dir.Sector, dir.Size); + cdutil->read_file(file, type, dir.Sector, dir.Size); delete file; } else if (!strcmp(argv[optind], "extract")) { - Handle * file; - optind++; if ((argc - 3) != optind) { showhelp(); printm(M_ERROR, "extract needs three arguments.\n"); - delete iso_r; - exit(-1); + throw Exit(-1); } arg1 = argv[optind++]; size = atoi(argv[optind++]); sector = atoi(argv[optind++]); file = new Output(arg1); printm(M_STATUS, "Reading %i bytes from sector %i to file %s.\n", size, sector, arg1); - read_file(iso_r, file, type, sector, size); + cdutil->read_file(file, type, sector, size); delete file; } else if (!strcmp(argv[optind], "insert-file")) { - struct DirEntry dir, * d; + cdutils::DirEntry dir, * d; unsigned char * buffer; - Handle * file; int old_type; if (ppf) { - if (open_ppf(ppf, iso_r, "Created by CD-Tool") < 0) { + if (cdutil->open_ppf(ppf, "Created by CD-Tool") < 0) { printm(M_ERROR, "Failed to open file %s for writing.\n", ppf); } } else { iso_w = new Output(iso_name, 0, 0); + cdutil->set_iso_w(iso_w); } optind++; if ((argc - 2) != optind) { showhelp(); printm(M_ERROR, "insert-file needs two arguments.\n"); - delete iso_r; - if (ppf) { - close_ppf(); - } else { - delete iso_w; - } - exit(-1); + throw Exit(-1); } arg1 = argv[optind++]; arg2 = argv[optind++]; file = new Input(arg1); - dir = find_path(iso_r, f = strdup(arg2)); + dir = cdutil->find_path(f = strdup(arg2)); free(f); if (!dir.R) { printm(M_ERROR, "Path %s was not found on iso.\n", arg2); - exit(-1); + throw Exit(-1); } - old_type = guess_type(iso_r, dir.Sector); + old_type = cdutil->guess_type(dir.Sector); if (type == GUESS) { type = old_type; @@ -219,86 +221,50 @@ int Main(int argc, char ** argv) { printm(M_WARNING, "New file too big: %i vs %i in " + sec_modes[type] + ".\n", dir.Size, file->GetSize()); } else { printm(M_ERROR, "New file too big: %i vs %i in " + sec_modes[type] + ".\n", dir.Size, file->GetSize()); - delete iso_r; - if (ppf) { - close_ppf(); - } else { - delete iso_w; - } - delete file; - exit(-1); + throw Exit(-1); } } - printm(M_STATUS, "Writing file %s at path %s.\n", arg1, arg2); - write_file(iso_r, iso_w, file, type, dir.Sector); + printm(M_STATUS, "Writing file %s at path %s (sector %i).\n", arg1, arg2, dir.Sector); + cdutil->write_file(file, type, dir.Sector); printm(M_STATUS, "Updating directory entry.\n"); - dir = find_parent(iso_r, f = strdup(arg2)); + dir = cdutil->find_parent(f = strdup(arg2)); free(f); if ((f = strrchr(arg2, '/'))) { f++; } else { f = arg2; } - d = find_dir_entry(iso_r, &buffer, &dir, f); + d = cdutil->find_dir_entry(&buffer, &dir, f); d->Size = file->GetSize(); - write_datas(iso_r, iso_w, buffer, GUESS, dir.Sector, dir.Size); + cdutil->write_datas(buffer, GUESS, dir.Sector, dir.Size); free(buffer); - delete file; - if (ppf) { - close_ppf(); - } else { - delete iso_w; - } } else if (!strcmp(argv[optind], "insert")) { - Handle * file; - if (ppf) { - if (open_ppf(ppf, iso_r, "Created by CD-Tool") < 0) { + if (cdutil->open_ppf(ppf, "Created by CD-Tool") < 0) { printm(M_ERROR, "Failed to open file %s for writing.\n", ppf); + throw Exit(-1); } } else { iso_w = new Output(iso_name, 0, 0); + cdutil->set_iso_w(iso_w); } optind++; if ((argc - 2) != optind) { showhelp(); printm(M_ERROR, "insert needs two arguments.\n"); - if (ppf) { - close_ppf(); - } else { - delete iso_w; - } - delete iso_r; - exit(-1); + throw Exit(-1); } arg1 = argv[optind++]; sector = atoi(argv[optind++]); file = new Input(arg1); printm(M_STATUS, "Writing file %s at sector %i.\n", arg1, sector); - write_file(iso_r, iso_w, file, type, sector); - if (ppf) { - close_ppf(); - } else { - delete iso_w; - } - delete file; + cdutil->write_file(file, type, sector); } else { showhelp(); printm(M_ERROR, "Command %s unknow.\n", argv[optind]); - delete iso_r; - exit(-1); - } - - delete iso_r; - exit(0); -} - -int main(int argc, char ** argv) { - try { - Main(argc, argv); - } - catch (GeneralException e) { - fprintf(stderr, "%s\n", e.GetMsg()); + throw Exit(-1); } + return 0; } +CODE_ENDS diff --git a/lzss-main.cpp b/lzss-main.cpp index 0a4a446..d2d9c68 100644 --- a/lzss-main.cpp +++ b/lzss-main.cpp @@ -25,11 +25,9 @@ #include "Output.h" #include "generic.h" #include "lzss.h" - -char * fn1, * fn2, * pname; +#include "Main.h" int lga = 0; -int lzsscompress = 1; struct option long_options[] = { {"1iscomp", 1, &lga, 1 }, @@ -70,6 +68,20 @@ struct option long_options[] = { {0, 0, NULL, 0 } }; +CODE_BEGINS +public: +Appli() : lzsscompress(1), lzss_o(new lzss) {} +virtual ~Appli() { + delete lzss_o; +} +private: + +char * fn1, * fn2, * pname; + +int lzsscompress; + +lzss * lzss_o; + void showhelp(void) { printm(M_BARE, "Usages:\n" @@ -100,6 +112,7 @@ void showhelp(void) { } void showscheme(void) { + lzss::scheme_t scheme = lzss_o->get_scheme(); printm(M_BARE, "Actual scheme:\n" "--1iscomp %i\n" @@ -139,16 +152,17 @@ void dump(void) { int i; printm(M_BARE, "Built-in schemes:\n"); - for (i = 0; schemes[i].name; i++) { - printm(M_BARE, "%2i - %s\n", i, schemes[i].name); + for (i = 0; lzss::schemes[i].name; i++) { + printm(M_BARE, "%2i - %s\n", i, lzss::schemes[i].name); } } -int main(int argc, char ** argv) { +virtual int startup() throw (GeneralException) { long length = -1; Handle * f1, * f2; int p, show = 0; int c, s, t; + lzss::scheme_t scheme = lzss_o->get_scheme(); pname = strdup(argv[0]); p = strlen(pname) - 5; @@ -159,8 +173,8 @@ int main(int argc, char ** argv) { lzsscompress = 0; } - printm(M_BARE, /* -LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ + printm(M_BARE, +LZSS_NAME + " compressor/decompressor version " + LZSS_VERSION + ",\n" "Copyright (C) 2002 Nicolas \"Pixel\" Noble\n" "This software comes with ABSOLUTELY NO WARRANTY; see COPYING for details\n" "Thanks to Czar Dragon, for his little 'lzss' schemes FAQ.\n" @@ -299,7 +313,11 @@ LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ exit(0); case 's': s = atoi(optarg); - scheme = schemes[s]; + if (s >= lzss_o->END) { + printm(M_ERROR, "%s: value too high (no such scheme)\n", s); + exit(-1); + } + scheme = lzss::schemes[s]; break; case 'l': length = atoi(optarg); @@ -323,7 +341,7 @@ LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ lzsscompress = 1; break; case 'b': - blockb = 1; + lzss_o->blockb = 1; break; default: showhelp(); @@ -357,24 +375,27 @@ LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ printm(M_STATUS, "Decompressing `%s' to `%s'...\n", fn1, fn2); } + lzss_o->change_scheme(scheme); + if (lzsscompress) { if (length == -1) { - lzss_comp(f1, f2); + lzss_o->lzss_comp(f1, f2); } else { - lzss_comp(f1, f2, &length); + lzss_o->lzss_comp(f1, f2, &length); } } else { - length = lzss_decomp(f1, f2, length); + length = lzss_o->lzss_decomp(f1, f2, length); } printm(M_STATUS, "Done, filesize changed from %i to %i.\n", f1->GetSize(), f2->GetSize()); - if (!bitmap_count) - bitmap_count = 8; + if (!lzss_o->bitmap_count) + lzss_o->bitmap_count = 8; if (lzsscompress) - printm(M_STATUS, "Compressed %i = 0x%08x blocs, containing %i = 0x%08x chunks.\n", blk + 1, blk + 1, blk * 8 + bitmap_count, blk * 8 + bitmap_count); + printm(M_STATUS, "Compressed %i = 0x%08x blocs, containing %i = 0x%08x chunks.\n", lzss_o->blk + 1, lzss_o->blk + 1, lzss_o->blk * 8 + lzss_o->bitmap_count, lzss_o->blk * 8 + lzss_o->bitmap_count); delete f1; delete f2; exit(0); } +CODE_ENDS |