author | ecalot
<ecalot> 2006-02-17 16:14:07 UTC |
committer | ecalot
<ecalot> 2006-02-17 16:14:07 UTC |
parent | 3eaa7c02626b8edd923fb0831cd801acd375cccb |
PR/src/include/common.h | +1 | -0 |
PR/src/include/palette.h | +3 | -0 |
PR/src/lib/object/object.c | +2 | -1 |
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/src/include/common.h b/PR/src/include/common.h index 26570f8..09107f7 100644 --- a/PR/src/include/common.h +++ b/PR/src/include/common.h @@ -222,6 +222,7 @@ PARSING_OPTRAW\ #define PR_RESULT_INDEX_NOT_FOUND -23 #define PR_RESULT_CHECKSUM_ERROR -24 #define PR_RESULT_ERR_WRONG_PRIMITIVE_CALL -19 +#define PR_RESULT_XML_AND_DAT_FORMAT_DO_NOT_MATCH -25 #define PR_RESULT_HELP_SHOWN -1 #define PR_RESULT_SUCCESS 0 diff --git a/PR/src/include/palette.h b/PR/src/include/palette.h index e869dd5..ca33274 100644 --- a/PR/src/include/palette.h +++ b/PR/src/include/palette.h @@ -60,4 +60,7 @@ tPalette createPalette(); int readPalette(tPalette* p, unsigned char* data, int dataSize); int applyPalette(tPalette* p,tImage *i); + +void* objPalette_pop1_4bitsCreate(unsigned char* data, int size, int *error); + #endif diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c index 7304d37..00775d7 100644 --- a/PR/src/lib/object/object.c +++ b/PR/src/lib/object/object.c @@ -35,6 +35,7 @@ main.c: Princed Resources : Main item class implementation #include "other.h" #include "image.h" +#include "palette.h" tObject getObject(tResource* r, int* error) { tObject o; @@ -50,7 +51,7 @@ tObject getObject(tResource* r, int* error) { o.obj=objBinaryCreate(r->data,r->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->data,r->size,error); break; case eResTypePcspeaker: /* save pcs file */ /*o.obj=objPcspeakerCreate(r->data,r->size,error); */ diff --git a/PR/src/lib/object/palette/pop1_16c.c b/PR/src/lib/object/palette/pop1_16c.c index 6bf0186..8c5b8c8 100644 --- a/PR/src/lib/object/palette/pop1_16c.c +++ b/PR/src/lib/object/palette/pop1_16c.c @@ -161,3 +161,33 @@ void addPop1Raw(tPalette* p,unsigned char* data, int dataSize) { p->pop1rawSize=dataSize; } + +typedef struct { + tColor c[16]; + unsigned char raw[100]; +}tPop1_4bitsPalette; + +void* objPalette_pop1_4bitsCreate(unsigned char* data, int size, int *error) { + int i; + tPop1_4bitsPalette* pal; + + if (size!=100) { + *error=PR_RESULT_XML_AND_DAT_FORMAT_DO_NOT_MATCH; + return NULL; + } + + pal=(tPop1_4bitsPalette*)malloc(sizeof(tPop1_4bitsPalette)); + + for (i=0;i<16;i++) { + pal->c[i].r=data[(i*3)+5]<<2; + pal->c[i].g=data[(i*3)+6]<<2; + pal->c[i].b=data[(i*3)+7]<<2; + } + + memcpy(pal->raw,data,100); + + *error=PR_RESULT_SUCCESS; + + return (void*)pal; +} + diff --git a/PR/src/lib/object/palette/pop2_256c.c b/PR/src/lib/object/palette/pop2_256c.c index 6bf0186..8c5b8c8 100644 --- a/PR/src/lib/object/palette/pop2_256c.c +++ b/PR/src/lib/object/palette/pop2_256c.c @@ -161,3 +161,33 @@ void addPop1Raw(tPalette* p,unsigned char* data, int dataSize) { p->pop1rawSize=dataSize; } + +typedef struct { + tColor c[16]; + unsigned char raw[100]; +}tPop1_4bitsPalette; + +void* objPalette_pop1_4bitsCreate(unsigned char* data, int size, int *error) { + int i; + tPop1_4bitsPalette* pal; + + if (size!=100) { + *error=PR_RESULT_XML_AND_DAT_FORMAT_DO_NOT_MATCH; + return NULL; + } + + pal=(tPop1_4bitsPalette*)malloc(sizeof(tPop1_4bitsPalette)); + + for (i=0;i<16;i++) { + pal->c[i].r=data[(i*3)+5]<<2; + pal->c[i].g=data[(i*3)+6]<<2; + pal->c[i].b=data[(i*3)+7]<<2; + } + + memcpy(pal->raw,data,100); + + *error=PR_RESULT_SUCCESS; + + return (void*)pal; +} + diff --git a/PR/src/lib/object/palette/pop2_4bit.c b/PR/src/lib/object/palette/pop2_4bit.c index 6bf0186..8c5b8c8 100644 --- a/PR/src/lib/object/palette/pop2_4bit.c +++ b/PR/src/lib/object/palette/pop2_4bit.c @@ -161,3 +161,33 @@ void addPop1Raw(tPalette* p,unsigned char* data, int dataSize) { p->pop1rawSize=dataSize; } + +typedef struct { + tColor c[16]; + unsigned char raw[100]; +}tPop1_4bitsPalette; + +void* objPalette_pop1_4bitsCreate(unsigned char* data, int size, int *error) { + int i; + tPop1_4bitsPalette* pal; + + if (size!=100) { + *error=PR_RESULT_XML_AND_DAT_FORMAT_DO_NOT_MATCH; + return NULL; + } + + pal=(tPop1_4bitsPalette*)malloc(sizeof(tPop1_4bitsPalette)); + + for (i=0;i<16;i++) { + pal->c[i].r=data[(i*3)+5]<<2; + pal->c[i].g=data[(i*3)+6]<<2; + pal->c[i].b=data[(i*3)+7]<<2; + } + + memcpy(pal->raw,data,100); + + *error=PR_RESULT_SUCCESS; + + return (void*)pal; +} +