summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FAQ.psx1
-rw-r--r--lz77.cpp31
-rw-r--r--lz77.h1
3 files changed, 27 insertions, 6 deletions
diff --git a/FAQ.psx b/FAQ.psx
index a16fbb2..6bb7fe8 100644
--- a/FAQ.psx
+++ b/FAQ.psx
@@ -16,3 +16,4 @@ A: http://www.psxdev.ip3.com/
http://phatt.hn.org/nitrous/psxutils.htm
http://www.geocities.com/SiliconValley/Pines/6131/psxprog.html
http://home.hiwaay.net/~jfrohwei/home.html
+ http://www.flyonthenet.it/net/psx_faq.htm
diff --git a/lz77.cpp b/lz77.cpp
index 4648964..8497868 100644
--- a/lz77.cpp
+++ b/lz77.cpp
@@ -29,6 +29,7 @@
int lz77_maxsize = 18;
int lz77_maxptr = 0x0fff;
int tolerate = 1;
+int blockb = 0;
scheme_t schemes[] = {
/* Nom 1 I J O N 16 Op F Lm1 Ls1 Lm2 Ls2 Jm1 Js1 Jm2 Js2 Fm1 Fs1 Fm2 Fs2 Vm1 Vs1 Vm2 Vs2 */
@@ -36,6 +37,7 @@ scheme_t schemes[] = {
{"DBZ RPG", 0, 0, 0, 0, 0, 0, 0, 0, 0x0f, 0, 0x00, 0, 0xf0, -4, 0xff, 4, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
{"FF7", 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0, 0x0f, 0, 0xff, 0, 0xf0, 4, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
{"Leen Mean", 1, 1, 1, 1, 0, 0, 0, 0, 0x0f, 0, 0x00, 0, 0xf0, 4, 0xff, 0, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
+ {"Metal Max", 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0, 0x0f, 0, 0xff, 0, 0xf0, 4, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
{"Ogre Battle", 0, 0, 0, 1, 0, 0, 1, 0, 0xf8, -3, 0x00, 0, 0x07, 8, 0xff, 0, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
{"Lodoss Wars", 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0, 0x7f, 0, 0xff, 0, 0x80, 1, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
{"FF6 PSX", 0, 0, 0, 1, 1, 1, 0, 0, 0x1f, 1, 0x00, 0, 0xe0, -4, 0xff, 4, 0x00, 0, 0x00, 0, 0x00, 0, 0x00, 0},
@@ -177,8 +179,11 @@ unsigned long lz77_decomp(FILE * f_source, FILE * f_cible, long true_length)
for (decomp_count = 0; decomp_count < decomp_fill; decomp_count++) {
fwrite(&valeur, 1, 1, f_cible);
text_buf[r++] = valeur;
- whole_count++;
+ if (!blockb)
+ whole_count++;
}
+ if (blockb)
+ whole_count++;
} else {
if (scheme.opposite) {
decomp_offset = r - lz77_maxptr - 1 + decomp_jump;
@@ -196,11 +201,12 @@ unsigned long lz77_decomp(FILE * f_source, FILE * f_cible, long true_length)
}
printm(M_INFO, " Found a needle of %li bytes at %li = 0x%04x, jump of %li = 0x%04x (val1 = 0x%02x, val2 = 0x%02x)\n", decomp_length, decomp_offset, decomp_offset, decomp_jump, decomp_jump, val1, val2);
for (decomp_count = decomp_offset; decomp_count < loop_length; decomp_count++) {
+ if (!blockb)
+ whole_count++;
if (decomp_count < 0) {
valeur = 0;
fwrite(&valeur, 1, 1, f_cible);
text_buf[r++] = 0;
- whole_count++;
if (!negative_error) {
if (!tolerate) {
free(text_buf);
@@ -214,11 +220,12 @@ unsigned long lz77_decomp(FILE * f_source, FILE * f_cible, long true_length)
fwrite(&text_buf[decomp_count], 1, 1, f_cible);
printm(M_INFO, "@0x%04x: 0x%02x\n", decomp_count, text_buf[decomp_count]);
text_buf[r++] = text_buf[decomp_count];
- whole_count++;
}
if (whole_count >= length)
- break;
+ break;
}
+ if (blockb)
+ whole_count++;
}
}
bitmap >>= 1;
@@ -278,9 +285,11 @@ long lz77_comp_strstr(unsigned char * needle, unsigned char * r, long * l, long
return ptr;
}
+long blk, bitmap_count;
+
unsigned char * lz77_memcomp(unsigned char * r, long * l, long * delta) {
- unsigned char bitmap, * comp, bitmap_count;
- long ptr, needle, needle_length, comp_ptr, bitmap_ptr, blk = 0, val1, val2;
+ unsigned char bitmap, * comp;
+ long ptr, needle, needle_length, comp_ptr, bitmap_ptr, val1, val2;
long jump, farest, remaining;
int j;
@@ -289,6 +298,7 @@ unsigned char * lz77_memcomp(unsigned char * r, long * l, long * delta) {
compute_limits();
ptr = 0;
+ blk = 0;
bitmap_count = 0;
comp_ptr = 1 + scheme.sixteen_bits;
bitmap = 0;
@@ -451,6 +461,7 @@ struct option long_options[] = {
{"dump", 0, NULL, 'D'},
{"compress", 0, NULL, 'c'},
{"decompress", 0, NULL, 'd'},
+ {"blocks", 0, NULL, 'b'},
{0, 0, NULL, 0 }
};
@@ -469,6 +480,7 @@ void showhelp(void) {
" or enable the padding behavior for compression.\n"
"-S --show Show the actual scheme before processing.\n"
"-v --verbose Display a *LOT* of informations.\n"
+"-b --blocks Switch to blocks decompression behaviour\n"
"\n"
"Additionnaly you have the scheme manipulation options:\n"
"--1iscomp --overlap --negative --16bits --filling --inverse --onejump\n"
@@ -700,6 +712,9 @@ LZ77_NAME " compressor/decompressor version " LZ77_VERSION ",\n"
case 'c':
compress = 1;
break;
+ case 'b':
+ blockb = 1;
+ break;
default:
showhelp();
printm(M_ERROR, "Unknow option.\n");
@@ -747,6 +762,10 @@ LZ77_NAME " compressor/decompressor version " LZ77_VERSION ",\n"
}
printm(M_STATUS, "Done, filesize changed from %i to %i.\n", filesize(f1), filesize(f2));
+ if (!bitmap_count)
+ bitmap_count = 8;
+ if (compress)
+ printm(M_STATUS, "Compressed %i = 0x%08x blocs, containing %i = 0x%08x chunks.\n", blk + 1, blk + 1, blk + bitmap_count, blk + bitmap_count);
fclose(f1);
fclose(f2);
diff --git a/lz77.h b/lz77.h
index 4158cd4..418578e 100644
--- a/lz77.h
+++ b/lz77.h
@@ -40,6 +40,7 @@ enum {
DBZ,
FF7,
LM,
+ MM,
OB,
LODOSS,
FF6,