git » fp-git.git » commit c7ac755

tested and bugfixed monochrome resources

author ecalot
2004-08-27 19:37:06 UTC
committer ecalot
2004-08-27 19:37:06 UTC
parent 9822aa84a2d28c358d8dfd9479eba0c515a811f6

tested and bugfixed monochrome resources

FP/src/conf/mods.conf +2 -2
FP/src/conf/resources.conf +4 -1
FP/src/conf/types.conf +0 -1
FP/src/ker/room.c +9 -3
FP/src/res/resources.c +28 -16

diff --git a/FP/src/conf/mods.conf b/FP/src/conf/mods.conf
index e726571..f35ccb9 100644
--- a/FP/src/conf/mods.conf
+++ b/FP/src/conf/mods.conf
@@ -5,5 +5,5 @@ HAS_L  0x08
 HAS_R  0x10
 WHITE  0x00
 RED    0x20
-GREEN  0x60
-BLUE   0x40
+GREEN  0x40
+BLUE   0x60
diff --git a/FP/src/conf/resources.conf b/FP/src/conf/resources.conf
index 4881ecd..a986c72 100644
--- a/FP/src/conf/resources.conf
+++ b/FP/src/conf/resources.conf
@@ -18,12 +18,15 @@ ANIM_RUN             IMG KID     400 407-414
 ANIM_RUN_START       IMG KID     400-406
 ANIM_RUN_STOP        IMG KID     400 465-468
 ANIM_RUN_TURN        IMG KID     400 465-477
-ANIM_TORCH           IMG PRINCE  150-159
 ANIM_TURNING         IMG KID     400 445-451
 ANIM_WALKING         IMG KID     400 534-544 
 GUARD_1              IMG PRINCE  GUARD 100 101
 IMG_BACKGROUND       IMG PV      950 951
 
+#common environment
+ANIM_TORCH           IMG PRINCE  150-159
+ANIM_POTION          IMG PRINCE  166-172
+
 #dungeon environment
 
 IMG_ENV_DUNGEON      IMG DUNGEON 200 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 269 270 271 272 273 274 285 292 293 294 295 296 297 298 299 300 324 325 326 344 346 347 348 349 350 351 351 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 1230 1231 1286 1287 1288 1289 1290 1291 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
diff --git a/FP/src/conf/types.conf b/FP/src/conf/types.conf
index e2073ba..1cee5fc 100644
--- a/FP/src/conf/types.conf
+++ b/FP/src/conf/types.conf
@@ -2,4 +2,3 @@
 
 IMG
 LVL
-PAL
diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c
index 010c050..42095f9 100644
--- a/FP/src/ker/room.c
+++ b/FP/src/ker/room.c
@@ -41,6 +41,7 @@ room.c: FreePrince : Room and Tile Object
 static struct {
 	tData* torch;
 	tData* environment;
+	tData* potionAnim;
 } roomGfx;
 
 void roomLoadGfx(long environment) {
@@ -50,12 +51,16 @@ void roomLoadGfx(long environment) {
 	roomGfx.environment=resLoad(environment);
 	if (roomGfx.torch==NULL) {
 		roomGfx.torch=resLoad(RES_ANIM_TORCH);
+		roomGfx.potionAnim=resLoad(RES_ANIM_POTION|RES_MODS_BW|RES_MODS_RED);
 	}
 }
 
 void roomFree() {
 	if (roomGfx.environment) resFree(roomGfx.environment);
-	if (roomGfx.torch) resFree(roomGfx.torch);
+	if (roomGfx.torch) {
+		resFree(roomGfx.torch);
+		resFree(roomGfx.potionAnim);
+	}
 	roomGfx.torch=(roomGfx.environment=NULL);
 }
 
@@ -387,8 +392,9 @@ void drawBackPanel(tRoom* room,int x, int y) {
 	/* torch/this */
 	if (tile.hasTorch) { /* animation */
 		outputDrawBitmap(
-			roomGfx.torch->pFrames[
-				(((tMap*)(room->level))->time+2*x+y)%(roomGfx.torch->frames)
+			roomGfx.potionAnim->pFrames[
+				/*(((tMap*)(room->level))->time+2*x+y)%(roomGfx.torch->frames)*/
+				(((tMap*)(room->level))->time+2*x+y)%(roomGfx.potionAnim->frames)
 			],
 			x*TILE_W+11,
 			y*TILE_H-39
diff --git a/FP/src/res/resources.c b/FP/src/res/resources.c
index 27bc68a..7f4fa2a 100644
--- a/FP/src/res/resources.c
+++ b/FP/src/res/resources.c
@@ -171,43 +171,55 @@ tData* resLoad(long id) {
 			int invert=((mask&(RES_MODS_INVERT))==(RES_MODS_INVERT));
 
 			result=(tData*)malloc(sizeof(tData));
-			result->frames=total-2; /* drop filename and palette */
 			result->type=eImages;
-			result->pFrames=(void**)malloc(result->frames*sizeof(void*));
 
 			if (!mReadBeginDatFile(&numberOfItems,res_file[res_list[from]])) {
 				printf("Fatal Error: resLoad: level file not found!\n");
 				return NULL;
 			}
 
-			if(!res_getDataById(res_list[from+1],numberOfItems,&palette)) {
-				printf("Fatal Error: resLoad: palette not found!\n");
-				return NULL;
-			}
-
-			if (palette.size!=100) {
-      	printf("Fatal error: resLoad: invalid palette\n");
-        return NULL;
-      }
 			if (mask&RES_MODS_BW) { /* if black and white */
 				/* this palette is white, red, green, blue */
 				static const char bwpalettes[]=BW_COLORS;
 				static char       bwpalette[]={0,0,0,0,0,0};
- 		    memcpy(bwpalette,bwpalettes+3*((mask>>5)&3),3);
+ 		    memcpy(bwpalette+3,bwpalettes+3*((mask>>5)&3),3);
 	      pal.colors=2;
 				pal.color=(tColor*)bwpalette;
+				result->frames=total-1; /* drop filename */
+				fprintf(stderr,"Loading a BW image with palette %d-%d-%d,%d-%d-%d color=%d\n",
+												bwpalette[0],
+												bwpalette[1],
+												bwpalette[2],
+												bwpalette[3],
+												bwpalette[4],
+												bwpalette[5],
+												((mask>>5)&3)
+												);
 			} else {
-	      pal.colors=16;
- 		    pal.color=(tColor*)(palette.array+5);
+				from++;
+				if(!res_getDataById(res_list[from],numberOfItems,&palette)) {
+					printf("Fatal Error: resLoad: palette not found!\n");
+					return NULL;
+				}
+				if (palette.size!=100) {
+     			printf("Fatal error: resLoad: invalid palette\n");
+					return NULL;
+				}
+				pal.colors=16;
+				pal.color=(tColor*)(palette.array+5);
+				result->frames=total-2; /* drop filename and palette */
 			}
+			from++;
+			result->pFrames=(void**)malloc(result->frames*sizeof(void*));
 			for (total=0;total<result->frames;total++) {
-				if(!res_getDataById(res_list[from+2+total],numberOfItems,&raw)) {
+				if(!res_getDataById(res_list[from+total],numberOfItems,&raw)) {
 					printf("Fatal Error: resLoad: image not found!\n");
 					return NULL;
 				}
 
 				/* get the offsets to move the image */
-				getOffsets(&down,&left,&right,from,has_D,has_L,has_R,result->frames,total);
+				if (pal.colors==16) /* available only for 16 colors images */
+				getOffsets(&down,&left,&right,from+2,has_D,has_L,has_R,result->frames,total);
 				
 				/* expand raw image into an image structure */
 				mExpandGraphic(raw.array,&image,raw.size);