git » fp-git.git » commit f2060e3

direction is now a mask in resLoad

author ecalot
2004-07-19 20:12:27 UTC
committer ecalot
2004-07-19 20:12:27 UTC
parent 7d908c5579ae0bca8f61ba95e6162e8abc07576a

direction is now a mask in resLoad

FP/src/include/resources.h +6 -1
FP/src/ker/kernel.c +4 -4
FP/src/res/resources.c +10 -16

diff --git a/FP/src/include/resources.h b/FP/src/include/resources.h
index 8aa6759..7f1a945 100644
--- a/FP/src/include/resources.h
+++ b/FP/src/include/resources.h
@@ -77,7 +77,12 @@ typedef struct {
 	void** pFrames;
 }tData;
 
-tData* resLoad(int id); 
+#define RES_MOD_RIGHT          0x00010000
+#define res_modIsRight(a) ((a)&0x0001)
+#define res_modGetId(a)   ((a)&0xffff)
+#define res_modGetMask(a) ((a)>>16)
+
+tData* resLoad(long id);
 /* Function for getting data previously loaded into memory. All id's are
  * defined in data.h generated by the resource manager and indexer.
  *
diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c
index 66915b5..de5cd02 100644
--- a/FP/src/ker/kernel.c
+++ b/FP/src/ker/kernel.c
@@ -46,10 +46,10 @@ int control(int optionflag,int level) {
 	tData* animation;
 	tData* fondo;
 	
-	runningAnimation[0]=resLoad(RES_ANIM_RUN_LEFT);
-	runningAnimation[1]=resLoad(RES_ANIM_RUN_RIGHT);
-	runningAnimation[2]=resLoad(RES_ANIM_JUMPRUN_LEFT);
-	runningAnimation[3]=resLoad(RES_ANIM_JUMPRUN_RIGHT);
+	runningAnimation[0]=resLoad(RES_ANIM_RUN);
+	runningAnimation[1]=resLoad(RES_ANIM_RUN|RES_MOD_RIGHT);
+	runningAnimation[2]=resLoad(RES_ANIM_JUMPRUN);
+	runningAnimation[3]=resLoad(RES_ANIM_JUMPRUN|RES_MOD_RIGHT);
 	fondo=resLoad(RES_IMG_BACKGROUND);
 	if (!fondo) {
 		printf("The resource couldn't be loaded!\n");
diff --git a/FP/src/res/resources.c b/FP/src/res/resources.c
index 3b60314..bee0877 100644
--- a/FP/src/res/resources.c
+++ b/FP/src/res/resources.c
@@ -59,10 +59,7 @@ tData* res_createData(int nFrames,int type) {
 	result=(tData*)malloc(sizeof(tData));
 	
 	switch (type) {
-		case RES_TYPE_IMG_TR_LEFT:
-		case RES_TYPE_IMG_TR_RIGHT:
-		case RES_TYPE_IMG_BL_LEFT:
-		case RES_TYPE_IMG_BL_RIGHT:
+		case RES_TYPE_IMG:
 			result->type=eImages;/*res_getVirtualTypeFromReal(res_getIdxType);*/
 			nFrames--;
 			break;
@@ -74,7 +71,7 @@ tData* res_createData(int nFrames,int type) {
 }
 
 /* Using the type and the array data this function will return the resources in void* fromat */
-void res_createFrames(tMemory data,int type,void** returnValue,int number) {
+void res_createFrames(tMemory data,int type,void** returnValue,int number,int mask) {
 	tMemory* result;
 	static tImage image;
 	static tPalette palette;
@@ -82,10 +79,7 @@ void res_createFrames(tMemory data,int type,void** returnValue,int number) {
 	palette.color=(tColor*)image.pal;
 
 	switch (type) {
-		case RES_TYPE_IMG_TR_LEFT:
-		case RES_TYPE_IMG_TR_RIGHT:
-		case RES_TYPE_IMG_BL_LEFT:
-		case RES_TYPE_IMG_BL_RIGHT:
+		case RES_TYPE_IMG:
 			if (!number) {
 				if (data.size!=100) {
 					printf("Fatal error: res_createFrames: invalid palette\n");
@@ -101,8 +95,8 @@ void res_createFrames(tMemory data,int type,void** returnValue,int number) {
 			/* TODO: the result must be an object created in output module: */
 			result=(void*)outputLoadBitmap(
 				image.pix,image.widthInBytes*image.height,palette,image.height,image.width,
-				(type==RES_TYPE_IMG_TR_RIGHT||type==RES_TYPE_IMG_BL_RIGHT),
-				(type==RES_TYPE_IMG_TR_RIGHT||type==RES_TYPE_IMG_TR_LEFT)
+				res_modIsRight(mask),
+				1
 			);
 			 
 			printf("res_createFrames: Allocating frame[%d]=? (image type %d)\n",number,type);
@@ -147,7 +141,7 @@ int res_getDataById(int id,int maxItems,tMemory* result) {
 	return (gotId==id); /* 1 if the id was found, 0 if not */
 }
 
-int res_getDataByArray(short int* id,int maxItems,void** result,int ids,int type) {
+int res_getDataByArray(short int* id,int maxItems,void** result,int ids,int type,int mask) {
 	/* This function looks for a data resource in a dat file optimizing the search knowing
 	 * that the id's starts in 0
 	 */
@@ -169,7 +163,7 @@ int res_getDataByArray(short int* id,int maxItems,void** result,int ids,int type
 				(unsigned long *)&(data.size)
 			);
 			if (gotId==id[i]) {
-				res_createFrames(data,type,result,i);
+				res_createFrames(data,type,result,i,mask);
 				i++;
 			}
 		}
@@ -191,7 +185,7 @@ int res_getDataByArray(short int* id,int maxItems,void** result,int ids,int type
  * Public functions
  * */
 
-tData* resLoad(int id) {
+tData* resLoad(long id) {
 				
 	/* Initialize abstract variables to read this new DAT file */
 	unsigned short int numberOfItems;
@@ -205,7 +199,7 @@ tData* resLoad(int id) {
 
 	/* READ INDEX */
 	if (!mReadBeginDatFile(&numberOfItems,"index.dat")) return NULL;
-	if (!res_getDataById(id,DATA_END_ITEMS,&index)) {
+	if (!res_getDataById(res_modGetId(id),DATA_END_ITEMS,&index)) {
 		printf("Fatal Error: resLoad: index could not be read!\n");
 		return NULL;
 	}
@@ -242,7 +236,7 @@ tData* resLoad(int id) {
 	result=res_createData(nFrames,res_getIdxType);
 
 	/* Fill pFrames into tData object */
-	if (!res_getDataByArray(frames,numberOfItems,result->pFrames,nFrames,res_getIdxType)) {
+	if (!res_getDataByArray(frames,numberOfItems,result->pFrames,nFrames,res_getIdxType,res_modGetMask(id))) {
 		printf("Fatal Error: resLoad: resource file invalid!\n");
 		free(frames);
 		free(result->pFrames);