author | ecalot
<ecalot> 2006-02-26 08:34:55 UTC |
committer | ecalot
<ecalot> 2006-02-26 08:34:55 UTC |
parent | d1cd722f69227a09f17bda209892780749ccffa5 |
PR/doc/changelog.txt | +6 | -3 |
PR/src/lib/formats/pal.c | +1 | -1 |
PR/src/lib/object/object.c | +2 | -2 |
PR/src/lib/object/palette/pop1_16c.c | +30 | -0 |
PR/src/lib/object/palette/pop2_256c.c | +30 | -0 |
PR/src/lib/object/palette/pop2_4bit.c | +30 | -0 |
diff --git a/PR/doc/changelog.txt b/PR/doc/changelog.txt index cb25159..a0ec3b4 100644 --- a/PR/doc/changelog.txt +++ b/PR/doc/changelog.txt @@ -157,7 +157,7 @@ Versions: - Rewritten resource handling using dynamic structures - Support of partial list folder selection wildcards (e.g. vdungeon.dat@vdungeon/chopper/*.bmp) '*' and '?' using '&' as escape - * PR v1.2 (scheduled 2006-02-22) + * PR v1.2 (scheduled 2006-03-22) - Added 8 bits palette support - Added defines for positive return values in XML + Added experimental POP2 RLEC decompression algorithm @@ -177,9 +177,11 @@ Versions: equivalencies + 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) + - When extracting, generated unknown.xml's are now all merged into one + * PR v1.3 (scheduled 2006-04-22) + x Fix ./pr -ie it -f bug + x Move tResource* from reslist to types.h X Add a fatal error check when importing from a different palette size and a warning when importing from an incorrect palette. x Added full POP2 RLEC decompression algorithm @@ -191,6 +193,7 @@ Versions: x Rename "uncompress" to "decomporess" x Replaced .bmp by .png files. x Transform flags from the hex form to the [a-y]* form (a is 1, b is 2, c is 4...) + X Don't create empry unknown.xml * PR v1.4 (future plans) x Added full POP2 RLEC compression algorithm x Code a palette adapting feature diff --git a/PR/src/lib/formats/pal.c b/PR/src/lib/formats/pal.c index a7523c2..b8beebf 100644 --- a/PR/src/lib/formats/pal.c +++ b/PR/src/lib/formats/pal.c @@ -53,7 +53,7 @@ int writePal(const char* file, int colors, const tColor* colorArray, int optionf /* open file */ if (!writeOpen(file,&fd,optionflag)) return PR_RESULT_ERR_FILE_NOT_WRITE_ACCESS; - fprintf(fd,"JASC-PAL\r\n%04d\r\n%d\r\n",100,colors); + fprintf(fd,"JASC-PAL\r\n0100\r\n%d\r\n",colors); for (i=0;i<colors;i++) { fprintf(fd,"%d %d %d\r\n", colorArray[i].r, diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c index fe41d9f..6c5f4fa 100644 --- a/PR/src/lib/object/object.c +++ b/PR/src/lib/object/object.c @@ -149,7 +149,7 @@ void setObject(tObject o,int *result,tResource* res) { *result=objPcspeakerSet(o.obj,res); break; case eResTypePop1Palette4bits: - /*o.obj=objPop1Palette4bitsRead(file,res.content,result);*/ + *result=objPop1Palette4bitsSet(o.obj,res); break; case eResTypeBinary: default: @@ -180,7 +180,7 @@ tObject readObject(const char* file,tResource* res,int *result) { o.obj=objPcspeakerRead(file,result); break; case eResTypePop1Palette4bits: - /*o.obj=objPop1Palette4bitsRead(file,res.content,result);*/ + o.obj=objPop1Palette4bitsRead(file,result); break; case eResTypeBinary: default: diff --git a/PR/src/lib/object/palette/pop1_16c.c b/PR/src/lib/object/palette/pop1_16c.c index 09016a9..4e9dfcc 100644 --- a/PR/src/lib/object/palette/pop1_16c.c +++ b/PR/src/lib/object/palette/pop1_16c.c @@ -40,6 +40,7 @@ palette.c: Princed Resources : The palette object implementation #include <stdio.h> #include "palette.h" #include "memory.h" +#include "dat.h" #include "pal.h" @@ -241,3 +242,32 @@ tColor* paletteGetColorArrayForColors(int colors) { return NULL; /* unsupported bit rate */ } } + +void* objPop1Palette4bitsRead(const char* file,int *result) { + tPop1_4bitsPalette* pal=(tPop1_4bitsPalette*)malloc(sizeof(tPop1_4bitsPalette)); + tColor* colorArray; + int colors; + + *result=readPal(file,&colorArray,&colors); + + if (*result==PR_RESULT_SUCCESS && colors!=16) { + *result=PR_WRONG_PALETTE_COLOR_COUNT; + free(colorArray); + return NULL; + } + memcpy(pal->c,colorArray,sizeof(tColor)*16); + free(colorArray); + + return (void*)pal; +} + +int objPop1Palette4bitsSet(void* o,tResource* res) { + tBinary* wave=o; + res->content.size=wave->size+1; + res->content.data=malloc(wave->size+1); + res->content.data[0]=0x01; /* TODO: use WAVE_MAGIC */ + memcpy(res->content.data+1,wave->data,wave->size); + mWriteFileInDatFile(res); + return PR_RESULT_SUCCESS; +} + diff --git a/PR/src/lib/object/palette/pop2_256c.c b/PR/src/lib/object/palette/pop2_256c.c index 09016a9..4e9dfcc 100644 --- a/PR/src/lib/object/palette/pop2_256c.c +++ b/PR/src/lib/object/palette/pop2_256c.c @@ -40,6 +40,7 @@ palette.c: Princed Resources : The palette object implementation #include <stdio.h> #include "palette.h" #include "memory.h" +#include "dat.h" #include "pal.h" @@ -241,3 +242,32 @@ tColor* paletteGetColorArrayForColors(int colors) { return NULL; /* unsupported bit rate */ } } + +void* objPop1Palette4bitsRead(const char* file,int *result) { + tPop1_4bitsPalette* pal=(tPop1_4bitsPalette*)malloc(sizeof(tPop1_4bitsPalette)); + tColor* colorArray; + int colors; + + *result=readPal(file,&colorArray,&colors); + + if (*result==PR_RESULT_SUCCESS && colors!=16) { + *result=PR_WRONG_PALETTE_COLOR_COUNT; + free(colorArray); + return NULL; + } + memcpy(pal->c,colorArray,sizeof(tColor)*16); + free(colorArray); + + return (void*)pal; +} + +int objPop1Palette4bitsSet(void* o,tResource* res) { + tBinary* wave=o; + res->content.size=wave->size+1; + res->content.data=malloc(wave->size+1); + res->content.data[0]=0x01; /* TODO: use WAVE_MAGIC */ + memcpy(res->content.data+1,wave->data,wave->size); + mWriteFileInDatFile(res); + return PR_RESULT_SUCCESS; +} + diff --git a/PR/src/lib/object/palette/pop2_4bit.c b/PR/src/lib/object/palette/pop2_4bit.c index 09016a9..4e9dfcc 100644 --- a/PR/src/lib/object/palette/pop2_4bit.c +++ b/PR/src/lib/object/palette/pop2_4bit.c @@ -40,6 +40,7 @@ palette.c: Princed Resources : The palette object implementation #include <stdio.h> #include "palette.h" #include "memory.h" +#include "dat.h" #include "pal.h" @@ -241,3 +242,32 @@ tColor* paletteGetColorArrayForColors(int colors) { return NULL; /* unsupported bit rate */ } } + +void* objPop1Palette4bitsRead(const char* file,int *result) { + tPop1_4bitsPalette* pal=(tPop1_4bitsPalette*)malloc(sizeof(tPop1_4bitsPalette)); + tColor* colorArray; + int colors; + + *result=readPal(file,&colorArray,&colors); + + if (*result==PR_RESULT_SUCCESS && colors!=16) { + *result=PR_WRONG_PALETTE_COLOR_COUNT; + free(colorArray); + return NULL; + } + memcpy(pal->c,colorArray,sizeof(tColor)*16); + free(colorArray); + + return (void*)pal; +} + +int objPop1Palette4bitsSet(void* o,tResource* res) { + tBinary* wave=o; + res->content.size=wave->size+1; + res->content.data=malloc(wave->size+1); + res->content.data[0]=0x01; /* TODO: use WAVE_MAGIC */ + memcpy(res->content.data+1,wave->data,wave->size); + mWriteFileInDatFile(res); + return PR_RESULT_SUCCESS; +} +