git » fp-git.git » commit e8a4927

fixed some files

author ecalot
2006-06-17 21:17:37 UTC
committer ecalot
2006-06-17 21:17:37 UTC
parent 3499499bc25dffeeb979089b304e9dd5b91cd75c

fixed some files

PR/src/lib/actions/export.c +5 -5
PR/src/lib/layers/dat.c +2 -4
PR/src/lib/object/image/image16.c +5 -4
PR/src/lib/object/image/image256.c +5 -5
PR/src/lib/object/image/image_common.c +5 -4
PR/src/lib/object/object.c +1 -1

diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index 623c243..01af2c5 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -72,7 +72,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 /*	tImage             image; * this is used to make a persistent palette */
 	tObject            currentPalette=getObject(NULL,&ok); /*TODO: move to pallist */
 	unsigned short int numberOfItems;
-	tResourceId        bufferedPalette={0,"",0};
+	tResourceId        nullPalette={0,"",0};
 /*	tPaletteList       paletteBuffer;*/
 	tResource          res;
 	tPL                palettes=pl_create();
@@ -84,7 +84,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 	/* initialize palette buffer */
 	/*paletteBuffer=paletteListCreate();*/
 	/* initialize the default palette */
-	pl_add(&palettes,currentPalette,bufferedPalette,lowPriority); /* The null object will be used until a palette is set */
+	pl_add(&palettes,currentPalette,nullPalette,lowPriority); /* The null object will be used until a palette is set */
 	ok=1;
 
 	/* main loop */
@@ -127,12 +127,12 @@ printf("new palette object: o=%p type=%d\n",o.obj,o.type);
 					case eResTypeImage16: /* save image */
 					case eResTypeImage256: { /* save image */
 						/* Palette handling */
-/*						if (resourceListCompareId(res.paletteId,bufferedPalette) * add &&!paletteCheckCompatibility(currentPalette,image) *) { * The palette isn't in the buffer */
 						tResource otherPalette;
 						int priorityRight;
 						tObject pal;
 						otherPalette.id=res.paletteId; /* TODO: use the try system */
-							/* Read the palette and load it into memory */
+						/* Read the palette and load it into memory */
+						if (resourceListCompareId(res.paletteId,nullPalette) /* add &&!paletteCheckCompatibility(currentPalette,image) */) { /* The palette isn't in the buffer */
 						if (mReadFileInDatFileId(&otherPalette)==PR_RESULT_SUCCESS) {
 							o=getObject(&otherPalette,&ok);
 printf("adding ");
@@ -148,7 +148,7 @@ showobj(o);
 						} else { /*, that's bad, I'll have to use the previous palette, even if it is the default */
 							printf("Warning: the selected palette doesn't exist in the file, the extracted image could result in a wrong palette\n");
 						}
-						 /* else, good, the palette is buffered */
+						}
 						/*res.palette=currentPalette;*/
 						o=getObject(&res,&ok);
 printf("getting the palette for the %d colours object ",paletteGetColors(o));	
diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c
index d6cecbe..3750cb2 100644
--- a/PR/src/lib/layers/dat.c
+++ b/PR/src/lib/layers/dat.c
@@ -401,12 +401,10 @@ int dat_readRes(tResource* res, tIndexCursor indexCursor) {
 	res->offset=          dat_readCursorGetOffset    (indexCursor);
 	res->content.size=    dat_readCursorGetSize      (indexCursor);
 	res->flags=           dat_readCursorGetFlags     (indexCursor);
+	res->content.isCopy=  1;
+	res->content.data=    readDatFile.data+res->offset+1; /* ignore the checksum */
 
-	/*res->size++; * add the checksum */
-
-	res->content.data=readDatFile.data+res->offset+1; /* ignore the checksum */
 	return checkSum(readDatFile.data+res->offset,res->content.size+1);
-/*printf("reading resource: %d:%4s at %d order=%d\n",res->id.value,res->id.index,res->offset,res->id.order);*/
 }
 
 void dat_releaseCursor(tIndexCursor* indexCursor) {
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index 1308fd0..1b6fae2 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -391,12 +391,13 @@ int objImage16Write(void* img,const char* file,int optionflag,const char* backup
 	tColor* colorArray;
 
 	if (i->pal.type!=eResTypeNone) {
-		bits=paletteGetBits(i->pal);
-		colors=paletteGetColors(i->pal);
+		bits=4; /*paletteGetBits(i->pal);*/
+		colors=16; /*paletteGetColors(i->pal);*/
 		colorArray=paletteGetColorArray(i->pal);
 	} else {
-		bits=getCarry(i->type);
-		colors=1<<bits;
+	/*	bits=getCarry(i->type);
+		colors=1<<bits;*/
+		colors=16;
 		colorArray=objPalette_16();
 	}
 	
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index 9d63bc6..3b8fce9 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -208,7 +208,7 @@ int pop2decompress(const unsigned char* input, int inputSize, int verify, unsign
 	int            tempOutputSize;
 	int            osCheck;
 
-	*output=malloc(40000);
+	*output=malloc(*outputSize);
 	lineO=*output;
 	for (aux=0;aux<*outputSize;aux++) (*output)[aux]=0; /* initialize the array (TODO: only for debug, in fixed images it won't be necessary) */
 	*outputSize=0;
@@ -252,7 +252,7 @@ int pop2decompress(const unsigned char* input, int inputSize, int verify, unsign
 		
 		lineI=tempOutput;
 
-		do {
+		while (lineSize==verify && tempOutputSize>0) {
 			aux=array2short(lineI);
 			lineI+=2;
 			if (aux>tempOutputSize) {
@@ -266,7 +266,7 @@ int pop2decompress(const unsigned char* input, int inputSize, int verify, unsign
 			tempOutputSize-=aux;
 			tempOutputSize-=2;
 			lineI+=aux;
-		} while (lineSize==verify && tempOutputSize>0);
+		}
 /*
 		aux=array2short(lineI);
 		lineI+=2;
@@ -358,8 +358,8 @@ int objImage256Write(void* img,const char* file,int optionflag,const char* backu
 		colors=paletteGetColors(i->pal);
 		colorArray=paletteGetColorArray(i->pal);
 	} else {
-		bits=getCarry(i->type);
-		colors=1<<bits;
+		bits=8; /*getCarry(i->type);*/
+		colors=256; /*1<<bits;*/
 		colorArray=objPalette_256();
 	}
 	
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index 1308fd0..1b6fae2 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -391,12 +391,13 @@ int objImage16Write(void* img,const char* file,int optionflag,const char* backup
 	tColor* colorArray;
 
 	if (i->pal.type!=eResTypeNone) {
-		bits=paletteGetBits(i->pal);
-		colors=paletteGetColors(i->pal);
+		bits=4; /*paletteGetBits(i->pal);*/
+		colors=16; /*paletteGetColors(i->pal);*/
 		colorArray=paletteGetColorArray(i->pal);
 	} else {
-		bits=getCarry(i->type);
-		colors=1<<bits;
+	/*	bits=getCarry(i->type);
+		colors=1<<bits;*/
+		colors=16;
 		colorArray=objPalette_16();
 	}
 	
diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c
index 2fb7fc2..92e9c17 100644
--- a/PR/src/lib/object/object.c
+++ b/PR/src/lib/object/object.c
@@ -161,7 +161,7 @@ int paletteGetColors(tObject object) { /* TODO: rename to objectGetColors */
 	case eResTypePop1PaletteMono: 
 		return  PAL_COLORS_eResTypePop1PaletteMono; /*2;*/
 	case eResTypeNone: 
-		return 256; /*256; TODO: use the object none object */
+		return 256; 
 	case eResTypeImage16:
 	case eResTypeImage2:
 	case eResTypeImage256: