git » fp-git.git » commit 91f2d85

encapsulated data array from tResource. Handled more return codes.

author ecalot
2006-02-19 22:18:03 UTC
committer ecalot
2006-02-19 22:18:03 UTC
parent 0c922fadf6686ab612b928a4f65e3905e4a09eed

encapsulated data array from tResource. Handled more return codes.

PR/doc/changelog.txt +1 -0
PR/src/include/binary.h +1 -1
PR/src/include/mid.h +2 -1
PR/src/include/reslist.h +5 -2
PR/src/include/sound.h +4 -1
PR/src/include/types.h +5 -2
PR/src/include/wav.h +2 -1
PR/src/lib/actions/classify.c +1 -1
PR/src/lib/actions/export.c +1 -1
PR/src/lib/actions/import.c +5 -5
PR/src/lib/formats/mid.c +9 -8
PR/src/lib/formats/plv.c +9 -9
PR/src/lib/formats/wav.c +19 -20
PR/src/lib/layers/dat.c +12 -12
PR/src/lib/layers/reslist.c +1 -1
PR/src/lib/object/image/image16.c +3 -3
PR/src/lib/object/image/image2.c +3 -3
PR/src/lib/object/image/image256.c +3 -3
PR/src/lib/object/image/image_common.c +3 -3
PR/src/lib/object/object.c +9 -6

diff --git a/PR/doc/changelog.txt b/PR/doc/changelog.txt
index 2f78eae..cb25159 100644
--- a/PR/doc/changelog.txt
+++ b/PR/doc/changelog.txt
@@ -178,6 +178,7 @@ Versions:
   + Inverted POP2 index names
   - Raw importation now works for pop2
   - When extracting, generated unknown.xml's are now merged into one
+  - Restructured the repository and source to support an object layer
  * PR v1.3 (scheduled 2006-03-22)
   X Add a fatal error check when importing from a different palette size and a
     warning when importing from an incorrect palette.
diff --git a/PR/src/include/binary.h b/PR/src/include/binary.h
index 2c97f25..1425b60 100644
--- a/PR/src/include/binary.h
+++ b/PR/src/include/binary.h
@@ -36,7 +36,7 @@ binary.h: Princed Resources : Memory handling & comparison prototypes
 
 typedef struct {
 	unsigned char* data;
-	int size;
+	long int size;
 }tBinary;
 
 #endif
diff --git a/PR/src/include/mid.h b/PR/src/include/mid.h
index 94872ab..63cde43 100644
--- a/PR/src/include/mid.h
+++ b/PR/src/include/mid.h
@@ -34,9 +34,10 @@ mid.h: Princed Resources : MIDI files support headers
 #ifndef _MID_H_
 #define _MID_H_
 
+#include "binary.h"
 #include "reslist.h"
 
 int mFormatImportMid(tResource *res);
-int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension);
+int writeMid(const char* file, tBinary* snd, int optionflag, const char* backupExtension);
 
 #endif
diff --git a/PR/src/include/reslist.h b/PR/src/include/reslist.h
index 89256a4..744b880 100644
--- a/PR/src/include/reslist.h
+++ b/PR/src/include/reslist.h
@@ -37,6 +37,8 @@ reslist.h: Princed Resources : Resource list prototypes
 #include "list.h" /* tList */
 typedef tList tResourceList;
 
+#include "binary.h"
+
 #include "common.h" /* Item Types */
 
 /* types */
@@ -55,14 +57,15 @@ typedef struct {
 	tResourceId        id;
 	tResourceId        paletteId;
 	tObject            palette;
-	long int           size;
+	/*long int           size;
+	unsigned char*     data;*/
+	tBinary            content;
 	unsigned long int  offset; /* Used internally in dat.c to remember the offset */
 	unsigned char      number; /* Used for level number */
 	tResourceType      type;
 	char*              desc;
 	char*              name;
 	char*              path;
-	unsigned char*     data;
 	unsigned long      flags;
 }tResource;
 
diff --git a/PR/src/include/sound.h b/PR/src/include/sound.h
index 96dacae..c9825f0 100644
--- a/PR/src/include/sound.h
+++ b/PR/src/include/sound.h
@@ -35,13 +35,16 @@ sound.h: Princed Resources :
 
 #include "binary.h"
 
+#include "mid.h"
+#include "wav.h"
+
 int objSoundWrite(void* o, const char* file, int write(const char* file,tBinary* data,int optionflag, const char* backupExtension), int optionflag, const char* backupExtension);
 void* objSoundCreate(unsigned char* data, int size, int *error);
 
 
 #define objWaveWrite(a,b,c,d) objSoundWrite(a,b,writeWav,c,d)
 #define objMidiWrite(a,b,c,d) objSoundWrite(a,b,writeMid,c,d)
-#define objPcspeakerWrite(a,b,c,d) objSoundWrite(a,b,writePcs,c,d)
+#define objPcspeakerWrite(a,b,c,d) objBinaryWrite(a,b,c,d)
 
 #define objWaveCreate(a,b,c) objSoundCreate(a,b,c)
 #define objMidiCreate(a,b,c) objSoundCreate(a,b,c)
diff --git a/PR/src/include/types.h b/PR/src/include/types.h
index 89256a4..744b880 100644
--- a/PR/src/include/types.h
+++ b/PR/src/include/types.h
@@ -37,6 +37,8 @@ reslist.h: Princed Resources : Resource list prototypes
 #include "list.h" /* tList */
 typedef tList tResourceList;
 
+#include "binary.h"
+
 #include "common.h" /* Item Types */
 
 /* types */
@@ -55,14 +57,15 @@ typedef struct {
 	tResourceId        id;
 	tResourceId        paletteId;
 	tObject            palette;
-	long int           size;
+	/*long int           size;
+	unsigned char*     data;*/
+	tBinary            content;
 	unsigned long int  offset; /* Used internally in dat.c to remember the offset */
 	unsigned char      number; /* Used for level number */
 	tResourceType      type;
 	char*              desc;
 	char*              name;
 	char*              path;
-	unsigned char*     data;
 	unsigned long      flags;
 }tResource;
 
diff --git a/PR/src/include/wav.h b/PR/src/include/wav.h
index 1dbae62..2da3aba 100644
--- a/PR/src/include/wav.h
+++ b/PR/src/include/wav.h
@@ -34,11 +34,12 @@ wav.h: Princed Resources : WAV files support headers
 #ifndef _WAV_H_
 #define _WAV_H_
 
+#include "binary.h"
 #include "reslist.h"
 
 #define WAVE_HEADER {0x52, 0x49, 0x46, 0x46, 0x12, 0x16, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x11, 0x2B, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61, 0xA3, 0x15, 0x00, 0x00}
 
-int mFormatExportWav(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension);
+int writeWav(const char* file, tBinary* snd, int optionflag, const char* backupExtension);
 int mFormatImportWav(tResource *res);
 
 #endif
diff --git a/PR/src/lib/actions/classify.c b/PR/src/lib/actions/classify.c
index 79cc3c3..c3ae529 100644
--- a/PR/src/lib/actions/classify.c
+++ b/PR/src/lib/actions/classify.c
@@ -65,7 +65,7 @@ int prClassifyDat(const char* vFiledat) {
 		if (ok==PR_RESULT_INDEX_NOT_FOUND) READ_ERROR; /* Read error */
 		/*if (ok==PR_RESULT_CHECKSUM_ERROR) fprintf(outputStream,"Warning: Checksum error\n"); Warning TODO: add an output for the checksum warning */
 		if (res.id.value==0xFFFF) continue; /* Tammo Jan Bug fix */
-		type=verifyHeader(res.data,res.size);
+		type=verifyHeader(res.content.data,res.content.size);
 	}
 
 	mReadCloseDatFile();
diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index 9b5ad0f..578ef8c 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -101,7 +101,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 		resourceListAddInfo(r,&res);
 
 		if (isInTheItemMatchingList(res.path,res.id)) { /* If the resource was specified do the tasks */
-			if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.data,res.size);
+			if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.content.data,res.content.size);
 			if (!(hasFlag(unknown_flag))) { /* If unknown flag is set do nothing but generate the unknown.xml file */
 				tObject o;
 				if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */
diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index d0286d0..89e281c 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -111,7 +111,7 @@ int import_full(const char* vFiledat, const char* vDirExt, tResourceList* r, int
 		if (hasFlag(raw_flag)) newRes.type=0; /* compile from raw */
 		getFileName(vFileext,vDirExt,res,vFiledat,vDatFileName,optionflag,backupExtension,NULL);
 		/* the file is in the archive, so I'll add it to the main DAT body */
-		if ((newRes.size=(mLoadFileArray(vFileext,&newRes.data)))>0) {
+		if ((newRes.content.size=(mLoadFileArray(vFileext,&newRes.content.data)))>0) { /* TODO: let each format handle the files */
 			if (!mAddCompiledFileToDatFile(&newRes,vFileext)) {
 				if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_ERRORS,getFileNameFromPath(vFileext));
 				error++;
@@ -119,7 +119,7 @@ int import_full(const char* vFiledat, const char* vDirExt, tResourceList* r, int
 				if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_SUCCESS,getFileNameFromPath(vFileext));
 				ok++;
 			}
-			free(newRes.data);
+			free(newRes.content.data);
 		} else {
 			if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_NOT_OPEN,getFileNameFromPath(vFileext));
 			error++;
@@ -167,14 +167,14 @@ int import_partial(const char* vFiledat, const char* vDirExt, tResourceList* r,
 		resourceListAddInfo(r,&res);
 
 		if (isInTheItemMatchingList(res.path,res.id)) { /* If the resource was specified */
-			if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.data,res.size);
+			if ((!res.type)&&(!hasFlag(raw_flag))) res.type=verifyHeader(res.content.data,res.content.size);
 			if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */
 
 			/* get save file name (if unknown document is in the XML) */
 			getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,NULL);
 
 			/* the file is in the partial matching list, so I'll import */
-			if ((newRes.size=mLoadFileArray(vFileext,&newRes.data))>0) {
+			if ((newRes.content.size=mLoadFileArray(vFileext,&newRes.content.data))>0) {
 				newRes.id=res.id;
 				newRes.type=res.type;
 				if (!mAddCompiledFileToDatFile(&newRes,vFileext)) {
@@ -184,7 +184,7 @@ int import_partial(const char* vFiledat, const char* vDirExt, tResourceList* r,
 					if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_SUCCESS,getFileNameFromPath(vFileext));
 					ok++;
 				}
-				free(newRes.data);
+				free(newRes.content.data);
 			} else {
 				if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_NOT_OPEN,getFileNameFromPath(vFileext));
 				errors++;
diff --git a/PR/src/lib/formats/mid.c b/PR/src/lib/formats/mid.c
index 1951a42..5d768c2 100644
--- a/PR/src/lib/formats/mid.c
+++ b/PR/src/lib/formats/mid.c
@@ -39,20 +39,21 @@ mid.c: Princed Resources : MIDI files support
 #include <stdlib.h>
 #include <string.h>
 
-int mFormatExportMid(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension) {
-	/* Mid files are saved as raw except you must ignore checksum & sound type */
-	return writeData(data,2,vFileext,size,optionflag,backupExtension);
+int writeMid(const char* file, tBinary* snd, int optionflag, const char* backupExtension) {
+	/* Mid files are saved as raw */
+	return writeData(snd->data,0,file,snd->size,optionflag,backupExtension)?PR_RESULT_SUCCESS:PR_RESULT_ERR_FILE_NOT_WRITE_ACCESS;
 }
 
 int mFormatImportMid(tResource *res) {
 	unsigned char* file;
 
-	file=malloc(res->size+1);
+	file=malloc(res->content.size+1);
 	file[0]=(unsigned char)((res->type==4)?2:0); /* Now should be 0x02: First character must be a 0x01 (wav type in DAT) */
-	memcpy(file+1,res->data,res->size);
-	res->size++;
-	free(res->data);
-	res->data=file;
+	memcpy(file+1,res->content.data,res->content.size);
+	res->content.size++;
+	free(res->content.data);
+	res->content.data=file;
 	mWriteFileInDatFile(res);
 	return 1; /* true */
 }
+
diff --git a/PR/src/lib/formats/plv.c b/PR/src/lib/formats/plv.c
index ec62840..7e6f5c9 100644
--- a/PR/src/lib/formats/plv.c
+++ b/PR/src/lib/formats/plv.c
@@ -174,30 +174,30 @@ int mFormatImportPlv(tResource *res) {
 	/* declare variables */
 	unsigned char* pos;
 	unsigned char* posAux;
-	unsigned long int oldSize=res->size;
+	unsigned long int oldSize=res->content.size;
 
 	/* integrity check 1 */
 	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE) return 0; /* false */
-	if (memcmp(res->data,PLV_HEADER_A,PLV_HEADER_A_SIZE)) return 0; /* false */
+	if (memcmp(res->content.data,PLV_HEADER_A,PLV_HEADER_A_SIZE)) return 0; /* false */
 
 	/* jump to size */
-	pos=res->data+PLV_HEADER_A_SIZE+7; /* TODO: check this */
+	pos=res->content.data+PLV_HEADER_A_SIZE+7; /* TODO: check this */
 
 	/* read size and jump to data */
-	res->size=array2long(pos);pos+=4;
+	res->content.size=array2long(pos);pos+=4;
 
 	/* integrity check 2 */
-	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE+res->size) return 0; /* false */
+	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE+res->content.size) return 0; /* false */
 
 	/* validate checksum */
-	if (!checkSum(pos,res->size))
+	if (!checkSum(pos,res->content.size))
 		fprintf(outputStream,PR_TEXT_IMPORT_PLV_WARN);
 
 	/* save data */
-	posAux=res->data;
-	res->data=pos;
+	posAux=res->content.data;
+	res->content.data=pos;
 	mWriteFileInDatFileIgnoreChecksum(res);
-	res->data=posAux;
+	res->content.data=posAux;
 
 	return 1; /* true */
 }
diff --git a/PR/src/lib/formats/wav.c b/PR/src/lib/formats/wav.c
index 5c6ec05..3f08763 100644
--- a/PR/src/lib/formats/wav.c
+++ b/PR/src/lib/formats/wav.c
@@ -36,43 +36,42 @@ wav.c: Princed Resources : WAV files support
 #include "disk.h"
 #include "wav.h"
 
-int mFormatExportWav(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension) {
+int writeWav(const char* file, tBinary* snd, int optionflag, const char* backupExtension) {
 	FILE*         target;
 	int ok;
 	unsigned char wav[]=WAVE_HEADER;
 
-	size-=2;
-	ok=writeOpen(vFileext,&target,optionflag);
+	ok=writeOpen(file,&target,optionflag);
 
-	wav[4]=(unsigned char)((size+36)&0xFF);
-	wav[5]=(unsigned char)(((size+36)>>8)&0xFF);
-	wav[6]=(unsigned char)(((size+36)>>16)&0xFF);
-	wav[7]=(unsigned char)(((size+36)>>24)&0xFF);
+	wav[4]=(unsigned char)((snd->size+36)&0xFF);
+	wav[5]=(unsigned char)(((snd->size+36)>>8)&0xFF);
+	wav[6]=(unsigned char)(((snd->size+36)>>16)&0xFF);
+	wav[7]=(unsigned char)(((snd->size+36)>>24)&0xFF);
 
-	wav[40]=(unsigned char)((size)&0xFF);
-	wav[41]=(unsigned char)(((size)>>8)&0xFF);
-	wav[42]=(unsigned char)(((size)>>16)&0xFF);
-	wav[43]=(unsigned char)(((size)>>24)&0xFF);
+	wav[40]=(unsigned char)((snd->size)&0xFF);
+	wav[41]=(unsigned char)(((snd->size)>>8)&0xFF);
+	wav[42]=(unsigned char)(((snd->size)>>16)&0xFF);
+	wav[43]=(unsigned char)(((snd->size)>>24)&0xFF);
 
 	ok=ok&&fwrite(wav,sizeof(wav),1,target);
-	ok=ok&&fwrite(data+2,size,1,target);
+	ok=ok&&fwrite(snd->data,snd->size,1,target);
 	ok=ok&&(!writeCloseOk(target,optionflag,backupExtension));
 
-	return ok;
+	return ok?PR_RESULT_SUCCESS:PR_RESULT_ERR_FILE_NOT_WRITE_ACCESS;
 }
 
 int mFormatImportWav(tResource *res) {
 	unsigned char wav[]=WAVE_HEADER;
 	int i=sizeof(wav);
-	unsigned char* posAux=res->data;
+	unsigned char* posAux=res->content.data;
 
-	if (res->size<=i) return 0; /* false */
-	res->size-=(--i);
-	while ((i==4||i==5||i==6||i==7||i==40||i==41||i==42||i==43||((res->data)[i]==wav[i]))&&(i--));
-	(res->data)[sizeof(wav)-1]=1; /* First character must be a 0x01 (wav type in DAT) */
-	res->data+=sizeof(wav)-1;
+	if (res->content.size<=i) return 0; /* false */
+	res->content.size-=(--i);
+	while ((i==4||i==5||i==6||i==7||i==40||i==41||i==42||i==43||((res->content.data)[i]==wav[i]))&&(i--));
+	(res->content.data)[sizeof(wav)-1]=1; /* First character must be a 0x01 (wav type in DAT) */
+	res->content.data+=sizeof(wav)-1;
 	if (i==-1) mWriteFileInDatFile(res);
-	res->data=posAux;
+	res->content.data=posAux;
 	return 1; /* true */
 }
 
diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c
index fc18f68..8f8e1a0 100644
--- a/PR/src/lib/layers/dat.c
+++ b/PR/src/lib/layers/dat.c
@@ -400,13 +400,13 @@ int dat_readRes(tResource* res, tIndexCursor indexCursor) {
 	strncpy(res->id.index,dat_readCursorGetIndexName (indexCursor),5);
 	res->id.order=        dat_readCursorGetOrder     (indexCursor);
 	res->offset=          dat_readCursorGetOffset    (indexCursor);
-	res->size=            dat_readCursorGetSize      (indexCursor);
+	res->content.size=    dat_readCursorGetSize      (indexCursor);
 	res->flags=           dat_readCursorGetFlags     (indexCursor);
 
 	/*res->size++; * add the checksum */
 
-	res->data=readDatFile+res->offset+1; /* ignore the checksum */
-	return checkSum(readDatFile+res->offset,res->size+1);
+	res->content.data=readDatFile+res->offset+1; /* ignore the checksum */
+	return checkSum(readDatFile+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);*/
 }
 
@@ -531,14 +531,14 @@ void dat_write(const tResource* res,unsigned char checksum) {
 	/* remember only indexed values */
 	insert.id=res->id;
 	insert.flags=res->flags;
-	insert.size=res->size;
+	insert.content.size=res->content.size;
 	insert.offset=((unsigned long)ftell(writeDatFile));
 
 	/* writes the checksum */
 	fwritechar(&checksum,writeDatFile);
 
 	/* do the magic */
-	fwrite(res->data,res->size,1,writeDatFile);
+	fwrite(res->content.data,res->content.size,1,writeDatFile);
 
 	resourceListAdd(&resIndex,&insert);
 }
@@ -550,11 +550,11 @@ void mWriteFileInDatFileIgnoreChecksum(const tResource* res) {
 	aux=*res;
 
 	/* drop the checksum */
-	aux.data++;
-	aux.size--;
+	aux.content.data++;
+	aux.content.size--;
 
 	/* write it */
-	dat_write(&aux,res->data[0]);
+	dat_write(&aux,res->content.data[0]);
 }
 
 void mWriteFileInDatFile(const tResource* res) {
@@ -564,9 +564,9 @@ void mWriteFileInDatFile(const tResource* res) {
 	 */
 
 	/* Declare variables */
-	int            k        = res->size;
+	int            k        = res->content.size;
 	unsigned char  checksum = 0;
-	const unsigned char* dataAux  = res->data;
+	const unsigned char* dataAux  = res->content.data;
 
 	/* calculates the checksum */
 	while (k--) checksum+=*(dataAux++);
@@ -597,7 +597,7 @@ void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension
 				totalItems++;
 				fwriteshort(&(res->id.value),writeDatFile);
 				fwritelong(&(res->offset),writeDatFile);
-				fwriteshort(&(res->size),writeDatFile);
+				fwriteshort(&(res->content.size),writeDatFile);
 			} while ((res=resourceListGetElement(&resIndex)));
 			size2+=totalItems<<3;
 
@@ -655,7 +655,7 @@ void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension
 				fwriteshort(&(res->id.value),writeDatFile);
 /*printf("writing resource: %d:%4s at %d f=%08x\n",res->id.value,res->id.index,res->offset,res->flags);*/
 				fwritelong(&(res->offset),writeDatFile);
-				fwriteshort(&(res->size),writeDatFile);
+				fwriteshort(&(res->content.size),writeDatFile);
 
 				/* this is the flag written in endian-safe */
 				v=res->flags>>16;
diff --git a/PR/src/lib/layers/reslist.c b/PR/src/lib/layers/reslist.c
index 3f2105b..f2a4761 100644
--- a/PR/src/lib/layers/reslist.c
+++ b/PR/src/lib/layers/reslist.c
@@ -119,7 +119,7 @@ void resourceListAdd(tResourceList* r,tResource* res) {
 void printr(const tResource* record) {
 		printf("id=(%d,%s,%d)\n",record->id.value,record->id.index,record->id.order);
 		/*printf("palette=(%d,%s)\n",record->palette.value,record->palette.index);*/
-		printf("size=%ld offset=%lu\n",record->size,record->offset);
+		printf("size=%ld offset=%lu\n",record->content.size,record->offset);
 		/*printf("number=%d type=%d\n",record->number,record->type);*/
 		/*printf("path='%s' name='%s' desc='%s'\n\n",record->path,record->name,record->desc);*/
 }
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index c4a8912..174e367 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -451,9 +451,9 @@ void objImageFree(void* img) {
 int mFormatImportBmp(tResource *res) {
 	tImage img;
 
-	if (!mReadBitMap(&img,res->data,res->size)) return 0; /* false */
-	free(res->data);
-	mCompressGraphic(&(res->data),&img,(int*)&(res->size));
+	if (!mReadBitMap(&img,res->content.data,res->content.size)) return 0; /* false */
+	free(res->content.data);
+	mCompressGraphic(&(res->content.data),&img,(int*)&(res->content.size));
 	mWriteFileInDatFile(res);
 	free(img.pix);
 
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index c4a8912..174e367 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -451,9 +451,9 @@ void objImageFree(void* img) {
 int mFormatImportBmp(tResource *res) {
 	tImage img;
 
-	if (!mReadBitMap(&img,res->data,res->size)) return 0; /* false */
-	free(res->data);
-	mCompressGraphic(&(res->data),&img,(int*)&(res->size));
+	if (!mReadBitMap(&img,res->content.data,res->content.size)) return 0; /* false */
+	free(res->content.data);
+	mCompressGraphic(&(res->content.data),&img,(int*)&(res->content.size));
 	mWriteFileInDatFile(res);
 	free(img.pix);
 
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index c4a8912..174e367 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -451,9 +451,9 @@ void objImageFree(void* img) {
 int mFormatImportBmp(tResource *res) {
 	tImage img;
 
-	if (!mReadBitMap(&img,res->data,res->size)) return 0; /* false */
-	free(res->data);
-	mCompressGraphic(&(res->data),&img,(int*)&(res->size));
+	if (!mReadBitMap(&img,res->content.data,res->content.size)) return 0; /* false */
+	free(res->content.data);
+	mCompressGraphic(&(res->content.data),&img,(int*)&(res->content.size));
 	mWriteFileInDatFile(res);
 	free(img.pix);
 
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index c4a8912..174e367 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -451,9 +451,9 @@ void objImageFree(void* img) {
 int mFormatImportBmp(tResource *res) {
 	tImage img;
 
-	if (!mReadBitMap(&img,res->data,res->size)) return 0; /* false */
-	free(res->data);
-	mCompressGraphic(&(res->data),&img,(int*)&(res->size));
+	if (!mReadBitMap(&img,res->content.data,res->content.size)) return 0; /* false */
+	free(res->content.data);
+	mCompressGraphic(&(res->content.data),&img,(int*)&(res->content.size));
 	mWriteFileInDatFile(res);
 	free(img.pix);
 
diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c
index 193c894..6f4ff99 100644
--- a/PR/src/lib/object/object.c
+++ b/PR/src/lib/object/object.c
@@ -56,22 +56,22 @@ tObject getObject(tResource* r, int* error) {
 	case eResTypeBinary: /* Binary files */
 	case eResTypeText: /* Text files */
 	case eResTypeRaw: /* Raw files */
-		o.obj=objBinaryCreate(r->data,r->size,error); 
+		o.obj=objBinaryCreate(r->content.data,r->content.size,error); 
 		break;
 	case eResTypePop1Palette4bits: /* save and remember palette file */
-		o.obj=objPalette_pop1_4bitsCreate(r->data,r->size,error);
+		o.obj=objPalette_pop1_4bitsCreate(r->content.data,r->content.size,error);
 		break;
 	case eResTypePcspeaker: /* save pcs file */
-		o.obj=objPcspeakerCreate(r->data,r->size,error);
+		o.obj=objPcspeakerCreate(r->content.data,r->content.size,error);
 		break;
 	case eResTypeMidi:	/* save midi file */
-		o.obj=objMidiCreate(r->data,r->size,error);
+		o.obj=objMidiCreate(r->content.data,r->content.size,error);
 		break;
 	case eResTypeWave: /* save wav file */
-		o.obj=objWaveCreate(r->data,r->size,error);
+		o.obj=objWaveCreate(r->content.data,r->content.size,error);
 		break;
 	case eResTypeImage: /* save image */
-		o.obj=objImageCreate(r->data,r->size,r->palette,error);
+		o.obj=objImageCreate(r->content.data,r->content.size,r->palette,error);
 		break;
 	default:
 		break;
@@ -93,10 +93,13 @@ int writeObject(tObject o, const char* file, int optionflag, const char* backupE
 		error=objPalette_pop1_4bitsWrite(o.obj,file,optionflag,backupExtension);
 		break;
 	case eResTypePcspeaker: /* save pcs file */
+		error=objPcspeakerWrite(o.obj,file,optionflag,backupExtension);
 		break;
 	case eResTypeMidi:	/* save midi file */
+		error=objMidiWrite(o.obj,file,optionflag,backupExtension);
 		break;
 	case eResTypeWave: /* save wav file */
+		error=objWaveWrite(o.obj,file,optionflag,backupExtension);
 		break;
 	case eResTypeImage: /* save image */
 		error=objImageWrite(o.obj,file,optionflag,backupExtension);