git » fp-git.git » commit 21e1e8e

pop2 n colors palettes hooked but not tested

author ecalot
2006-03-07 12:16:55 UTC
committer ecalot
2006-03-07 12:16:55 UTC
parent c2b9b6a0d4d79f0a41ec06396cac1d63ddcf76ad

pop2 n colors palettes hooked but not tested

PR/src/include/common.h +1 -1
PR/src/include/palette.h +5 -0
PR/src/lib/layers/autodetect.c +1 -1
PR/src/lib/object/object.c +9 -0
PR/src/lib/object/palette/pop2_256c.c +5 -0

diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index 3ad857f..1f4dcb1 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -97,7 +97,7 @@ typedef enum {
 	eResTypePop1Palette4bits=8,
 	eResTypePop1PaletteGuards=9,
 	eResTypePop1PaletteMono=10,
-	eResTypePop2Palette320colors=11,
+	eResTypePop2PaletteNColors=11,
 	eResTypePop2Palette4bits=12,
 	eResTypeText=13,
 	eResTypeWave=14
diff --git a/PR/src/include/palette.h b/PR/src/include/palette.h
index 707913a..7859439 100644
--- a/PR/src/include/palette.h
+++ b/PR/src/include/palette.h
@@ -66,8 +66,13 @@ void* objPalette_pop1_4bitsCreate(tBinary c, int *error);
 int objPalette_pop1_4bitsWrite(void* o, const char* file, int optionflag, const char* backupExtension);
 void* objPop1Palette4bitsRead(const char* file,int *result);
 int objPop1Palette4bitsSet(void* o,tResource* res);
+void* objPop2PaletteNColorsCreate(tBinary cont, int *error);
+int objPop2PaletteNColorsWrite(void* o, const char* file, int optionflag, const char* backupExtension);
+void* objPop2PaletteNColorsRead(const char* file,int *result);
+int objPop2PaletteNColorsSet(void* o,tResource* res);
 
 tColor* objPalette_pop1_4bitsGetColors(void* o);
+tColor* objPalette_pop2_ncolorsGetColors(void* o);
 
 /* middle layer */
 #define to8bits_A(a) (((a)<<2)|((a)>>4))
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index f17aca7..d072e8e 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -120,7 +120,7 @@ tResourceType verifyHeader(tBinary c) { /* TODO: add the pop version as another
 	if (verifyImage256Header (c)) return eResTypeImage256;
 	if (verifyPaletteHeaderPop1  (c)) return eResTypePop1Palette4bits;
 /*	if (verifyPaletteHeaderPop2  (c)) return eResTypePop2Palette4bits;*/
-	if (verifyPaletteHeaderPop2_256  (c)) return eResTypePop2Palette320colors;
+	if (verifyPaletteHeaderPop2_256  (c)) return eResTypePop2PaletteNColors;
 	if (verifyWaveHeader     (c)) return eResTypeWave;
 	if (verifySpeakerHeader  (c)) return eResTypePcspeaker;
 	return eResTypeBinary;
diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c
index 5ac6b95..2eb1ff9 100644
--- a/PR/src/lib/object/object.c
+++ b/PR/src/lib/object/object.c
@@ -63,6 +63,9 @@ tObject getObject(tResource* r, int* error) {
 	case eResTypePop1Palette4bits: /* save and remember palette file */
 		o.obj=objPalette_pop1_4bitsCreate(r->content,error);
 		break;
+	case eResTypePop2PaletteNColors: /* save and remember palette file */
+		o.obj=objPop2PaletteNColorsCreate(r->content,error);
+		break;
 	case eResTypePcspeaker: /* save pcs file */
 		o.obj=objPcspeakerCreate(r->content,error);
 		break;
@@ -133,6 +136,8 @@ printf("hello\n");
 
 int paletteGetBits(tObject pal) {
 	switch (pal.type) {
+	case eResTypePop2PaletteNColors:
+		return 8;
 	case eResTypePop1Palette4bits: 
 		return 4;
 	case eResTypePop1PaletteMono: 
@@ -144,6 +149,8 @@ int paletteGetBits(tObject pal) {
 			
 int paletteGetColors(tObject pal) {
 	switch (pal.type) {
+	case eResTypePop2PaletteNColors:
+		return 256;
 	case eResTypePop1Palette4bits: 
 		return 16;
 	case eResTypePop1PaletteMono: 
@@ -157,6 +164,8 @@ tColor* paletteGetColorArray(tObject pal) {
 	switch (pal.type) {
 	case eResTypePop1Palette4bits: /* save and remember palette file */
 		return objPalette_pop1_4bitsGetColors(pal.obj);
+	case eResTypePop2PaletteNColors:
+		return objPalette_pop2_ncolorsGetColors(pal.obj);
 	default:
 		return NULL;
 	}
diff --git a/PR/src/lib/object/palette/pop2_256c.c b/PR/src/lib/object/palette/pop2_256c.c
index beba842..0432a27 100644
--- a/PR/src/lib/object/palette/pop2_256c.c
+++ b/PR/src/lib/object/palette/pop2_256c.c
@@ -75,6 +75,11 @@ void* objPop2PaletteNColorsCreate(tBinary cont, int *error) {
 	return (void*)r;
 }
 
+tColor* objPalette_pop2_ncolorsGetColors(void* o) {
+	tGenericPalette* pal=o;
+	return pal->colorArray;
+}
+
 int objPop2PaletteNColorsWrite(void* o, const char* file, int optionflag, const char* backupExtension) {
 	tGenericPalette* p=o;
 	return writePal(file,p->size,p->colorArray,optionflag,backupExtension);