git » fp-git.git » commit 5e1fe3b

re hooked

author ecalot
2006-06-13 23:41:22 UTC
committer ecalot
2006-06-13 23:41:22 UTC
parent 0612e4e9857c97acb5ea2a7582f76617d4742bd7

re hooked

PR/src/Makefile +1 -2
PR/src/include/pallist.h +23 -0
PR/src/lib/actions/export.c +6 -5
PR/src/lib/layers/pallist.c +25 -28

diff --git a/PR/src/Makefile b/PR/src/Makefile
index 65e1bce..6f7d8c5 100644
--- a/PR/src/Makefile
+++ b/PR/src/Makefile
@@ -58,8 +58,7 @@ COMPRESS = .lzg_compress.o .lzg_decompress.o .rle_compress.o .rle_decompress.o .
 LAYERS   = .dat.o .memory.o .list.o .reslist.o .pallist.o .disk.o .idlist.o .autodetect.o .stringformat.o .resourcematch.o .auxiliary.o
 FORMAT   = .bmp.o .mid.o .pal.o .wav.o .plv.o
 OBJECT   = .object.o .pop2_256c.o .pop2_4bit.o .pop1_4bit.o .image2.o .image16.o .image256.o .binary.o .sounds.o .level.o
-CONSOLE  = 
-#.main.o .filedir.o
+CONSOLE  = .main.o .filedir.o
 MAIN     = .pr.o
 
 EXEOBJ   = $(MAIN) $(XML) $(COMPRESS) $(ACTIONS) $(LAYERS) $(OBJECT) $(FORMAT) $(PORTS) $(CONSOLE)
diff --git a/PR/src/include/pallist.h b/PR/src/include/pallist.h
index bbf2b9b..241124c 100644
--- a/PR/src/include/pallist.h
+++ b/PR/src/include/pallist.h
@@ -49,4 +49,27 @@ typedef struct {
 
 tPaletteList paletteListCreate();
 
+typedef enum {highPriority, lowPriority}tPriority;
+typedef struct pln{
+	tResourceId resid;			 
+	tObject*    object;
+	struct pln* next;
+}	tPL_Node;
+
+typedef struct {
+	struct {
+		tResourceId idres;			 
+		tObject*    object;
+	} priority_field;
+	tPL_Node*   list_first;
+	tPL_Node*   list_deleted_first;
+}	tPL;
+
+void pl_free  (tPL* pl);
+int  pl_tryAdd(tPL* pl, tResourceId resid, tPriority p);
+int  pl_add   (tPL* pl, tObject* o, tResourceId resid, tPriority p);
+int  pl_hasPriority(tPL* pl, tResourceId resid);
+tPL  pl_create();
+tObject* pl_get(tPL* pl, int* priorityRight, int colors);
+
 #endif
diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index b9bc0f5..d343a70 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -69,20 +69,21 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 	int                indexNumber;
 	int                ok;
 /*	tImage             image; * this is used to make a persistent palette */
-	tObject            currentPalette;
+	tObject            currentPalette=getObject(NULL,&ok); /*TODO: move to pallist */
 	unsigned short int numberOfItems;
-	tPaletteList       paletteBuffer;
 	tResourceId        bufferedPalette={0,"",0};
-	tResource          res;
+/*	tPaletteList       paletteBuffer;
+	tResource          res;*/
+	tPL                palettes=pl_create();
 	int                count=0;
 
 	/* Initialize abstract variables to read this new DAT file */
 	if ((ok=mReadBeginDatFile(&numberOfItems,vFiledat))) return ok;
 
 	/* initialize palette buffer */
-	paletteBuffer=paletteListCreate();
+	/*paletteBuffer=paletteListCreate();*/
 	/* initialize the default palette */
-	currentPalette=getObject(NULL,&ok); /* The null object will be used until a palette is set */
+	pl_add(&palettes,&currentPalette,bufferedPalette,lowPriority); /* The null object will be used until a palette is set */
 	ok=1;
 
 	/* main loop */
diff --git a/PR/src/lib/layers/pallist.c b/PR/src/lib/layers/pallist.c
index c3f344c..0134352 100644
--- a/PR/src/lib/layers/pallist.c
+++ b/PR/src/lib/layers/pallist.c
@@ -47,35 +47,30 @@ tPaletteList paletteListCreate() {
 
 /* Priority list */
 #include <stdlib.h>
-
 #include "object.h"
 
+#ifdef DEBUG_TEST_PALLST
 void showobj(tObject o) {
 	printf("object type=%d colors=%d\n",o.type,paletteGetColors(o));
+}
+#endif
+
+#if 0
+pl_dellist_add(tPL* pl, tResourceId idres, tObject* obj) {
+	/* TODO: use an ordered list */
+	/*	result=resourceListCompareId(idres,);*/
+	tPL_Node* node=pl->list_deleted_first;
+
+	while (node) {
+		if (resourceListCompareId(node->resid,idres)==0)e
+	}
+	
+	
+
+				
 }
 
-typedef enum {highPriority, lowPriority}tPriority;
-typedef struct pln{
-	tResourceId resid;			 
-	tObject*    object;
-	struct pln* next;
-}	tPL_Node;
-
-typedef struct {
-	struct {
-		tResourceId idres;			 
-		tObject*    object;
-	} priority_field;
-	tPL_Node*   list_first;
-	tPL_Node*   list_deleted_first;
-}	tPL;
-
-void pl_free  (tPL* pl);
-int  pl_tryAdd(tPL* pl, tResourceId resid, tPriority p);
-int  pl_add   (tPL* pl, tObject* o, tResourceId resid, tPriority p);
-int  pl_hasPriority(tPL* pl, tResourceId resid);
-tPL  pl_create();
-tObject* pl_get(tPL* pl, int* priorityRight, int colors);
+#endif
 
 tPL  pl_create() {
 	tPL r;
@@ -96,7 +91,7 @@ int  pl_tryAdd(tPL* pl, tResourceId resid, tPriority p) {
 	return 0; /* always false, optimization disabled */
 }
 
-int pl_add(tPL* pl, tObject* o, tResourceId resid, tPriority p) {
+void pl_add(tPL* pl, tObject* o, tResourceId resid, tPriority p) {
 	if (p==highPriority) {
 		/* high priority insertion */
 		if (pl->priority_field.object) { /* if there was another object proprized, move it to the list */
@@ -115,8 +110,8 @@ int pl_add(tPL* pl, tObject* o, tResourceId resid, tPriority p) {
 		int colors=paletteGetColors(*o);
 		
 		while (pl->list_first && colors>=paletteGetColors(*(pl->list_first->object))) {
-			printf("deleting: ");
-			showobj(*pl->list_first->object);
+			/*printf("deleting: ");
+			showobj(*pl->list_first->object);*/
 			pl->list_first=pl->list_first->next; /* Delete */
 		}
 		insertNode->next=pl->list_first;
@@ -124,7 +119,7 @@ int pl_add(tPL* pl, tObject* o, tResourceId resid, tPriority p) {
 		insertNode->resid=resid;
 		pl->list_first=insertNode;
 	}
-	return 1;
+	return;
 }
 
 tObject* pl_get(tPL* pl, int* priorityRight, int colors) {
@@ -147,6 +142,7 @@ tObject* pl_get(tPL* pl, int* priorityRight, int colors) {
 	return node?node->object:NULL;
 }
 
+#ifdef DEBUG_TEST_PALLST
 int main(int a,char** b) {
 	tObject tests[]={
 		{eResTypeNone,NULL},
@@ -166,7 +162,7 @@ int main(int a,char** b) {
 	pl_add(&pl, tests+1, ress[1], lowPriority);
 	pl_add(&pl, tests, ress[0], lowPriority);
 	pl_add(&pl, tests, ress[1], highPriority);
-	pl_add(&pl, tests+2, ress[0], highPriority);
+	pl_add(&pl, tests, ress[1], lowPriority);
 
 	{
 		tPL_Node* nodo=pl.list_first;
@@ -206,4 +202,5 @@ int main(int a,char** b) {
 	}
 	return 0;
 }
+#endif