author | ecalot
<ecalot> 2006-06-20 04:31:24 UTC |
committer | ecalot
<ecalot> 2006-06-20 04:31:24 UTC |
parent | b9bfde61d670cb07edc63939abef884b490670e8 |
PR/src/include/object.h | +1 | -5 |
PR/src/include/other.h | +9 | -2 |
PR/src/include/palette.h | +5 | -12 |
PR/src/lib/object/image/image16.c | +2 | -13 |
PR/src/lib/object/image/image_common.c | +2 | -13 |
PR/src/lib/object/level/level_common.c | +3 | -3 |
PR/src/lib/object/object.c | +7 | -1 |
diff --git a/PR/src/include/object.h b/PR/src/include/object.h index eb084a4..cf3f735 100644 --- a/PR/src/include/object.h +++ b/PR/src/include/object.h @@ -42,10 +42,6 @@ int objectWrite(tObject o, const char* file, int optionflag, const char* backupE tObject objectRead(const char* file,tResource* newRes,int *result); void objectSet(tObject o,int *result,tResource* res); -int objectPaletteGetBits(tObject pal); -int objectGetColors(tObject pal); -tColor* objectGetColorsArray(tObject pal); - -int getColorsByType(tResourceType type); +int objectGetColors(tObject obj); #endif diff --git a/PR/src/include/other.h b/PR/src/include/other.h index 820ab9b..b79751e 100644 --- a/PR/src/include/other.h +++ b/PR/src/include/other.h @@ -40,7 +40,14 @@ int objectBinaryWrite(void* o, const char* file, int optionflag, const char* bac void* objBinaryRead(const char* file,int *result); int objBinarySet(void* o,tResource* res); -void* objectLevelPop1Create(tBinary content,int number,const char* datfile,const char* name,const char* desc,const char* datAuthor,int *error); /* TODO: move to level.h */ -int objectLevelPop1Write(void* o, const char* file, int optionflag, const char* backupExtension); +/* TODO: move to level.h */ + +#define objectLevelPop1Create(a,b,c,d,e,f,g) objectLevelCreate(a,b,c,d,e,f,g) +#define objectLevelPop2Create(a,b,c,d,e,f,g) objectLevelCreate(a,b,c,d,e,f,g) +#define objectLevelPop1Write(a,b,c,d) objectLevelWrite(a,b,c,d,1) +#define objectLevelPop2Write(a,b,c,d) objectLevelWrite(a,b,c,d,2) + +void* objectLevelCreate(tBinary content,int number,const char* datfile,const char* name,const char* desc,const char* datAuthor,int *error); +int objectLevelWrite(void* o, const char* file, int optionflag, const char* backupExtension,int popVersion); #endif diff --git a/PR/src/include/palette.h b/PR/src/include/palette.h index b34209c..4c2ce07 100644 --- a/PR/src/include/palette.h +++ b/PR/src/include/palette.h @@ -54,13 +54,6 @@ pal.h: Princed Resources : JASC PAL files support headers {0xff,0x50,0xff},\ {0xff,0xf8,0x50},\ {0xff,0xff,0xff}} -/* -int getPalette(const tPalette* p, int bits, const tColor** palette); -int setPalette(tPalette* p, int bits, tColor* palette); -tPalette createPalette(); -int readPalette(tPalette* p, unsigned char* data, int dataSize); -int applyPalette(tPalette* p,tImage *i); -*/ void* objPalette_pop2_4bitsCreate(tBinary c, int *error); int objPalette_pop2_4bitsWrite(void* o, const char* file, int optionflag, const char* backupExtension); @@ -68,14 +61,12 @@ void* objectPalettePop1_16Create(tBinary c, int *error); int objectPalettePop1_16Write(void* o, const char* file, int optionflag, const char* backupExtension); void* objectPalettePop1_16Read(const char* file,int *result); int objectPalettePop1_16Set(void* o,tResource* res); -/*int objPop2Palette4bitsSet(void* o,tResource* res);*/ void* objectPalettePop2_NColorsCreate(tBinary cont, int *error); int objectPalettePop2_NColorsWrite(void* o, const char* file, int optionflag, const char* backupExtension); void* objPop2PaletteNColorsRead(const char* file,int *result); int objPop2PaletteNColorsSet(void* o,tResource* res); tColor* objectPalettePop1_16GetColors(void* o); -tColor* objPalette_pop2_4bitsGetColors(void* o); tColor* objectPalettePop2_NColorsGetColors(void* o); /* middle layer */ @@ -88,10 +79,12 @@ tColor* objectPalettePop2_NColorsGetColors(void* o); /* Hooks */ #define PAL_COLORS_eResTypePalettePop2_NColors getColorsByPop2PaletteObject(object.obj) -#define PAL_COLORS_eResTypePalettePop1_16 16 -#define PAL_COLORS_eResTypePalettePop1_Mono 2 +#define PAL_COLORS_eResTypePalettePop1_16 16 +#define PAL_COLORS_eResTypePalettePop1_Mono 2 -int getColorsByPop2PaletteObject(void* o); +int getColorsByPop2PaletteObject(void* o); /* TODO: rename by objectPalettePop2_NColorsGetColors */ +int objectPaletteGetBits(tObject pal); +tColor* objectGetColorsArray(tObject pal); /* TODO: rename by objectPaletteGetColorsArray */ #endif diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c index 27a3f2a..f9384db 100644 --- a/PR/src/lib/object/image/image16.c +++ b/PR/src/lib/object/image/image16.c @@ -386,23 +386,12 @@ void* objectImage16Create(tBinary cont, int *error) { /* use get like main.c */ int objectImage16Write(void* img,const char* file,int optionflag,const char* backupExtension) { tImage* i=img; - int bits; - int colors; tColor* colorArray; - if (i->pal.type!=eResTypeNone) { - bits=4; /*objectPaletteGetBits(i->pal);*/ - colors=16; /*objectGetColors(i->pal);*/ - colorArray=objectGetColorsArray(i->pal); - } else { - /* bits=getCarry(i->type); - colors=1<<bits;*/ - colors=16; - colorArray=objPalette_16(); - } + colorArray=(i->pal.type!=eResTypeNone)?objectGetColorsArray(i->pal):objPalette_16(); /* Write bitmap */ - return mWriteBmp(file,i->pix,i->width,i->height,bits,colors,colorArray,i->widthInBytes,optionflag,backupExtension); + return mWriteBmp(file,i->pix,i->width,i->height,4,16,colorArray,i->widthInBytes,optionflag,backupExtension); } void objectImageFree(void* img) { diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c index 27a3f2a..f9384db 100644 --- a/PR/src/lib/object/image/image_common.c +++ b/PR/src/lib/object/image/image_common.c @@ -386,23 +386,12 @@ void* objectImage16Create(tBinary cont, int *error) { /* use get like main.c */ int objectImage16Write(void* img,const char* file,int optionflag,const char* backupExtension) { tImage* i=img; - int bits; - int colors; tColor* colorArray; - if (i->pal.type!=eResTypeNone) { - bits=4; /*objectPaletteGetBits(i->pal);*/ - colors=16; /*objectGetColors(i->pal);*/ - colorArray=objectGetColorsArray(i->pal); - } else { - /* bits=getCarry(i->type); - colors=1<<bits;*/ - colors=16; - colorArray=objPalette_16(); - } + colorArray=(i->pal.type!=eResTypeNone)?objectGetColorsArray(i->pal):objPalette_16(); /* Write bitmap */ - return mWriteBmp(file,i->pix,i->width,i->height,bits,colors,colorArray,i->widthInBytes,optionflag,backupExtension); + return mWriteBmp(file,i->pix,i->width,i->height,4,16,colorArray,i->widthInBytes,optionflag,backupExtension); } void objectImageFree(void* img) { diff --git a/PR/src/lib/object/level/level_common.c b/PR/src/lib/object/level/level_common.c index 78b1895..9c9b4f8 100644 --- a/PR/src/lib/object/level/level_common.c +++ b/PR/src/lib/object/level/level_common.c @@ -55,7 +55,7 @@ typedef struct { const char* datAuthor; }tPop1Level; -void* objectLevelPop1Create(tBinary content,int number,const char* datfile,const char* name,const char* desc,const char* datAuthor,int *error) { +void* objectLevelCreate(tBinary content,int number,const char* datfile,const char* name,const char* desc,const char* datAuthor,int *error) { tPop1Level* r; *error=PR_RESULT_SUCCESS; /*TODO: fix the original file name path (lala///lele/demo.plv--> demo.plv) */ @@ -70,9 +70,9 @@ void* objectLevelPop1Create(tBinary content,int number,const char* datfile,const return (void*)r; } -int objectLevelPop1Write(void* o, const char* file, int optionflag, const char* backupExtension) { +int objectLevelWrite(void* o, const char* file, int optionflag, const char* backupExtension,int version) { tPop1Level* b=o; - return writePlv(file,b->content,b->content.size==12025?2:1,b->datfile,b->number,file,b->desc,b->name,b->datAuthor,optionflag,backupExtension); + return writePlv(file,b->content,version,b->datfile,b->number,file,b->desc,b->name,b->datAuthor,optionflag,backupExtension); } /* diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c index f2b4018..8bea77f 100644 --- a/PR/src/lib/object/object.c +++ b/PR/src/lib/object/object.c @@ -55,6 +55,9 @@ tObject objectCreate(tResource* r, int* error) { case eResTypeLevelPop1: o.obj=objectLevelPop1Create(r->content,r->number,r->datfile,r->name,r->desc,r->datAuthor,error); break; + case eResTypeLevelPop2: + o.obj=objectLevelPop2Create(r->content,r->number,r->datfile,r->name,r->desc,r->datAuthor,error); + break; case eResTypeOtherBinary: /* Binary files */ case eResTypeOtherText: /* Text files */ case eResTypeOtherRaw: /* Raw files */ @@ -100,6 +103,9 @@ int objectWrite(tObject o, const char* file, int optionflag, const char* backupE case eResTypeLevelPop1: error=objectLevelPop1Write(o.obj,file,optionflag,backupExtension); break; + case eResTypeLevelPop2: + error=objectLevelPop2Write(o.obj,file,optionflag,backupExtension); + break; case eResTypeOtherBinary: /* Binary files */ case eResTypeOtherText: /* Text files */ case eResTypeOtherRaw: /* Raw/autodetect files */ @@ -152,7 +158,7 @@ int objectPaletteGetBits(tObject pal) { } } -int objectGetColors(tObject object) { /* TODO: rename to objectGetColors */ +int objectGetColors(tObject object) { switch (object.type) { case eResTypePalettePop2_NColors: return PAL_COLORS_eResTypePalettePop2_NColors;