git » fp-git.git » commit f8523a6

uncommented new animation player and finished the abstraction of tKid (renamed to tObject now)

author ecalot
2005-01-09 22:39:49 UTC
committer ecalot
2005-01-09 22:39:49 UTC
parent f7ab4ed6cbd3ed5b893c1d22f951ee9a4ad386e3

uncommented new animation player and finished the abstraction of tKid (renamed to tObject now)

FP/src/Makefile +4 -2
FP/src/conf/anims.conf +2 -2
FP/src/conf/awk/anims_conf.awk +14 -1
FP/src/include/anims.h +4 -1
FP/src/include/kid.h +5 -5
FP/src/include/maps.h +2 -2
FP/src/include/object.h +5 -5
FP/src/include/states.h +2 -2
FP/src/include/types.h +2 -1
FP/src/ker/kernel.c +6 -4
FP/src/ker/kid.c +26 -27
FP/src/ker/object.c +26 -27
FP/src/ker/states.c +4 -4
FP/src/ker/titles.c +73 -8
FP/src/res/anims.c +4 -2
FP/src/res/maps.c +1 -1

diff --git a/FP/src/Makefile b/FP/src/Makefile
index 233d365..5c5f367 100644
--- a/FP/src/Makefile
+++ b/FP/src/Makefile
@@ -149,7 +149,8 @@ dat.o: res/dat.c include/disk.h include/dat.h
 	$(CC) -c res/dat.c $(OPTIONS)
 
 kernel.o: ker/kernel.c include/kernel.h include/resources.h\
-          include/res_conf.h include/output.h
+          include/res_conf.h include/output.h include/kid.h\
+          $(GENERATEDSTAHEADERS)
 	$(INFO) Compiling main kernel...
 	$(CC) -c ker/kernel.c $(OPTIONS)
 
@@ -166,7 +167,8 @@ kid.o: ker/kid.c include/kid.h include/resources.h include/res_conf.h\
 	$(CC) -c ker/kid.c $(OPTIONS)
 
 titles.o: ker/titles.c include/resources.h include/res_conf.h\
-          include/anims_conf.h $(GENERATEDSTAHEADERS) $(GENERATEDRESHEADERS)
+          include/anims_conf.h $(GENERATEDSTAHEADERS) $(GENERATEDRESHEADERS)\
+          include/kid.h
 	$(INFO) Compiling kernel titles module...
 	$(CC) -c ker/titles.c $(OPTIONS)
 
diff --git a/FP/src/conf/anims.conf b/FP/src/conf/anims.conf
index bc4372a..f525a0d 100644
--- a/FP/src/conf/anims.conf
+++ b/FP/src/conf/anims.conf
@@ -9,8 +9,8 @@ ANIMATION presentation 1000
 	0      FIXEDIMG img_princess_room   infinite bottom        #princess room
 	0      FIXEDIMG img_princess_bed    infinite bottom 98 124 #bed
 	0      FIXEDIMG img_princess_pillar infinite top    98 124 #pillar
-	#frame type     res                 state
-	0      STATE    img_jaffar          jaffar
+	#frame type     res                 state    Location Floor   Mirror
+	0      STATE    img_jaffar          jaffar   100      center  no
 	#frame type     res
 	#0     MIDI     
 	#0     WAV      
diff --git a/FP/src/conf/awk/anims_conf.awk b/FP/src/conf/awk/anims_conf.awk
index ff3c779..976d6d6 100644
--- a/FP/src/conf/awk/anims_conf.awk
+++ b/FP/src/conf/awk/anims_conf.awk
@@ -71,9 +71,22 @@ BEGIN {
 #states
 /^[[:space:]]*[[:digit:]]+[[:space:]]+STATE[[:space:]]/ {
 	totalstate++
+	$6=tolower($6)
+	$7=tolower($7)
+	
 	t["frame" totalstate]=$1/1
 	t["res" totalstate]=toupper($3)
 	t["state" totalstate]=toupper($4)
+	t["location" totalstate]=$5/1
+	if ($6=="up") $6=1
+	if ($6=="middle") $6=2
+	if ($6=="center") $6=2
+	if ($6=="down") $6=3
+	t["floor" totalstate]=$6/1
+	if ($7=="no") $7=0
+	if ($7=="yes") $7=1
+	if ($7=="mirror") $7=1
+	t["cacheMirror" totalstate]=$7/1
 	animation["sizet" animcount]++
 	halt
 }
@@ -126,7 +139,7 @@ END {
 	coma=""
 	printf("#define ANIMS_STATE {")
 	for (i=1;i<=totalstate;i++) {
-		printf("%s\\\n\t{/*frame*/ %d,/*res*/ (unsigned long)RES_%s, /*state*/ STATE_MARKS_%s}",coma,t["frame" i],t["res" i],t["state" i])
+		printf("%s\\\n\t{/*frame*/ %d, /*res*/ (unsigned long)RES_%s, /*state*/ STATE_MARKS_%s, /*loc*/ %d, /*floor*/%d, /*mirror*/ %d}",coma,t["frame" i],t["res" i],t["state" i],t["location" i],t["floor" i],t["cacheMirror" i])
 		coma=","
 	}
 	printf("\\\n}\n\n")
diff --git a/FP/src/include/anims.h b/FP/src/include/anims.h
index 083d90c..b48f60d 100644
--- a/FP/src/include/anims.h
+++ b/FP/src/include/anims.h
@@ -51,6 +51,9 @@ typedef struct {
 	unsigned short frame;
 	unsigned long res;
 	unsigned short state;
+	unsigned short location;
+	unsigned char floor;
+	unsigned char cacheMirror;
 } animState;
 
 typedef struct {
@@ -59,7 +62,7 @@ typedef struct {
 	enum {anims_enum_midi,anims_enum_wav,anims_enum_speaker} type;
 } animSound;
 
-int animStart(int animId);
+void animStart(int animId,int *qt,int *qf,int *qo);
 int animGetFrame(int* qf,int* qt,int* qo, animFixedimg* f,animState* t, animSound* o);
 
 #endif
diff --git a/FP/src/include/kid.h b/FP/src/include/kid.h
index 7462f34..f85eae1 100644
--- a/FP/src/include/kid.h
+++ b/FP/src/include/kid.h
@@ -19,7 +19,7 @@
 */
 
 /*
-kid.h: Free Prince : Kid object
+kid.h: Free Prince : Kid and other object
 \xaf\xaf\xaf\xaf\xaf
  Copyright 2004 Princed Development Team
   Created: 19 Jul 2004
@@ -42,10 +42,10 @@ kid.h: Free Prince : Kid object
 
 #include "types.h"
 
-tKid kidCreate();
-void kidDraw(tKid kid);
-int  kidMove(tKid* kid,tKey key,tRoom* room);
-void kidFree();
+tObject objectCreate(int location, int floor, int direction, int stateId, unsigned long resId,int cacheMirror);
+void objectDraw(tObject kid);
+int  objectMove(tObject* kid,tKey key,tRoom* room);
+void objectFree();
 
 #endif
 
diff --git a/FP/src/include/maps.h b/FP/src/include/maps.h
index db7d02a..8331636 100644
--- a/FP/src/include/maps.h
+++ b/FP/src/include/maps.h
@@ -36,7 +36,7 @@ maps.c: Freeprince : Map handling library
 #include "map_defs.h"
 #include "room.h"
 #include "resources.h" /* tMemory */
-#include "kid.h" /* tKid */
+#include "kid.h" /* tObject */
 
 #define MAP_ENVIRONMENTS {0,0,0,0,1,1,1,0,0,0,1,1,0,0,1,0}
 
@@ -48,7 +48,7 @@ void  mapFreeLevel(tMap* map);
 
 /* called from the kernel */
 tRoom mapGetRoom(tMap* map, tRoomId roomId);
-void  mapStart(tMap* map, tKid* kid, tRoomId* roomId, int level);
+void  mapStart(tMap* map, tObject* kid, tRoomId* roomId, int level);
 
 /* events */
 int  mapPressedTile(tMap* map, tTile tile, int s, int x, int y);
diff --git a/FP/src/include/object.h b/FP/src/include/object.h
index 7462f34..f85eae1 100644
--- a/FP/src/include/object.h
+++ b/FP/src/include/object.h
@@ -19,7 +19,7 @@
 */
 
 /*
-kid.h: Free Prince : Kid object
+kid.h: Free Prince : Kid and other object
 \xaf\xaf\xaf\xaf\xaf
  Copyright 2004 Princed Development Team
   Created: 19 Jul 2004
@@ -42,10 +42,10 @@ kid.h: Free Prince : Kid object
 
 #include "types.h"
 
-tKid kidCreate();
-void kidDraw(tKid kid);
-int  kidMove(tKid* kid,tKey key,tRoom* room);
-void kidFree();
+tObject objectCreate(int location, int floor, int direction, int stateId, unsigned long resId,int cacheMirror);
+void objectDraw(tObject kid);
+int  objectMove(tObject* kid,tKey key,tRoom* room);
+void objectFree();
 
 #endif
 
diff --git a/FP/src/include/states.h b/FP/src/include/states.h
index 449b0e3..33c091f 100644
--- a/FP/src/include/states.h
+++ b/FP/src/include/states.h
@@ -35,7 +35,7 @@ typedef struct {
  * and actions to be performed by this call
  *
  * Usage:
- *  stateUpdate(tKey* key, tKid* kid,tRoom* room);
+ *  stateUpdate(tKey* key, tObject* kid,tRoom* room);
  *  where key is a tKey* with the current key state (read from a file,
  *  keyboard or joystick) or NULL in case there is no need to interpretate
  *  key events to manipulate states
@@ -48,7 +48,7 @@ typedef struct {
  *  be performed.
  */
 
-short stateUpdate(tKey* key, tKid* kid,tRoom* room);
+short stateUpdate(tKey* key, tObject* kid,tRoom* room);
 
 /* Create a State depending on the level */
 int stateKidInLevel(int level);
diff --git a/FP/src/include/types.h b/FP/src/include/types.h
index bdd1fd9..1ad2879 100644
--- a/FP/src/include/types.h
+++ b/FP/src/include/types.h
@@ -133,8 +133,9 @@ typedef struct {
 	int location;
 	int floor;
 	int direction;
+	tData* gfxCache[2];
 	tState action;
-} tKid;
+} tObject;
 
 typedef enum {eLeft=0,eRight=1,eUp=2,eDown=3}tDirection;
 
diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c
index e8e02c3..1b45d1f 100644
--- a/FP/src/ker/kernel.c
+++ b/FP/src/ker/kernel.c
@@ -38,6 +38,7 @@ kernel.c: FreePrince : Main Kernel
 #include "output.h"
 #include "input.h"
 #include "titles.h"
+#include "states.h" /* stateKidInLevel */
 #include "kid.h"
 #include "room.h"
 #include "maps.h"
@@ -49,7 +50,8 @@ kernel.c: FreePrince : Main Kernel
 int playgame(int optionflag,int level) {
 	/* Create objects */
 	tKey    key=inputCreateKey();
-	tKid    kid=kidCreate();
+	/*TODO: use a map.c function that reads this information and creates the kid*/
+	tObject kid=objectCreate(30,1,DIR_RIGHT,stateKidInLevel(/*level*/1),RES_IMG_ALL_KID,1);
 	tData*  resMap=resLoad(RES_MAP|level);
 	tMap*   map=(tMap*)resMap->pFrames;
 	tRoom   room;
@@ -71,12 +73,12 @@ int playgame(int optionflag,int level) {
 			 * TODO: send to the real place where
 			 * the key is interpreted in kid object
 			 */
-			kidMove(&kid,key,&room);
+			objectMove(&kid,key,&room);
 			mapMove(map);
 			/* Drawing functions */
 			outputClearScreen(); /* TODO: send to drawBackground() */
 			roomDrawBackground(&room);
-			kidDraw(kid);
+			objectDraw(kid);
 			roomDrawForeground(&room);
 			outputUpdateScreen();
 		} else {
@@ -190,7 +192,7 @@ int kernel(int optionflag,int level) {
 		}
 	} while(!quit);
 
-	kidFree();
+	objectFree();
 	inputStopTimer();
 	outputStop();
 	return 0;
diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c
index 72eba69..fd1d0b8 100644
--- a/FP/src/ker/kid.c
+++ b/FP/src/ker/kid.c
@@ -19,7 +19,7 @@
 */
 
 /*
-kid.h: Free Prince : Kid object
+kid.h: Free Prince : Kid and other objects
 \xaf\xaf\xaf\xaf\xaf
  Copyright 2004 Princed Development Team
   Created: 19 Jul 2004
@@ -40,37 +40,36 @@ kid.h: Free Prince : Kid object
 
 #define NEW_KERNEL
 
-static struct {
-	tData* kid[2];
-} kidGfx;
-
-void loadGfx(int storeMirrored) {
-	kidGfx.kid[DIR_LEFT]=resLoad(RES_IMG_ALL_KID);
+void loadGfx(int storeMirrored, tData** gfxCache, unsigned long resId) {
+	gfxCache[DIR_LEFT]=resLoad(resId);
 	if (storeMirrored)
-		kidGfx.kid[DIR_RIGHT]=resLoad(RES_IMG_ALL_KID|RES_MODS_INVERT);
+		gfxCache[DIR_RIGHT]=resLoad(resId|RES_MODS_INVERT);
+	else
+		gfxCache[DIR_RIGHT]=NULL;
 }
 
-void kidFree() {
-	resFree(kidGfx.kid[DIR_LEFT]);
-	resFree(kidGfx.kid[DIR_RIGHT]);
+void objectFree(tData** gfxCache) {
+	resFree(gfxCache[DIR_LEFT]);
+	if (gfxCache[DIR_RIGHT]) resFree(gfxCache[DIR_RIGHT]);
 }
 
-/* TODO: send this function to maps.c */
-tKid kidCreate() {
-	tKid kid;
+/* TODO: make a function in maps.c that calls this one */
+tObject objectCreate(int location, int floor, int direction, int stateId, unsigned long resId,int cacheMirror) {
+	tObject object;
 
-	if (kidGfx.kid[0]==NULL) loadGfx(1);
+	loadGfx(cacheMirror,object.gfxCache,resId);
 
-	kid.location=30;
-	kid.floor=1;
-	kid.direction=DIR_RIGHT;
-	kid.action=createState(stateKidInLevel(1)); /* level 1 */
-	return kid;
+	object.location=location;
+	object.floor=floor;
+	object.direction=direction;
+	object.action=createState(stateId);
+	return object;
 }
 
-int kidVerifyRoom(tKid *kid,tRoom *room) {
+int objectVerifyRoom(tObject *kid,tRoom *room) {
 	/* if the kid is out of the screen we need to change the screen and put
 	 * the kid back again on it
+	 * PRE: tObject *kid is a kid
 	 */
 	
 	int refresh=0;
@@ -109,8 +108,8 @@ int kidVerifyRoom(tKid *kid,tRoom *room) {
 	
 #define kid_getLocation(kid,image) ((kid).location-(outputGetWidth(image)>>1))
 
-void kidDraw(tKid kid) {
-	void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1];
+void objectDraw(tObject kid) {
+	void* image=kid.gfxCache[kid.direction]->pFrames[stateGetImage(kid)-1];
 	/* TODO: move this -1 to each script frame */
 	outputDrawBitmap(
 		image, 
@@ -119,7 +118,7 @@ void kidDraw(tKid kid) {
 	);
 }
 
-int kidMove(tKid* kid,tKey key,tRoom* room) {
+int objectMove(tObject* kid,tKey key,tRoom* room) {
 	/* advance state and get the flag, then interpret the flag and do the events */
 	short flags;
 	int refresh=0;
@@ -127,9 +126,9 @@ int kidMove(tKid* kid,tKey key,tRoom* room) {
 	
 	flags=stateUpdate(&key,kid,room);
 
-	if (room==NULL) return flags;
+	if (room==NULL) return flags; /* exits if it is not associated to a room */
 	
-	x=kid_getLocation(*kid,kidGfx.kid[kid->direction]->pFrames[stateGetImage(*kid)-1])/TILE_W;
+	x=kid_getLocation(*kid,kid->gfxCache[kid->direction]->pFrames[stateGetImage(*kid)-1])/TILE_W;
 	
 	if (flags&STATES_FLAG_P)
 		refresh=mapPressedTile(
@@ -145,7 +144,7 @@ printf("f era %d. ",kid->floor);
 	if (flags&STATES_FLAG_U)
 		kid->floor--;
 printf("f pasa a ser %d\n",kid->floor);
-	refresh=kidVerifyRoom(kid,room)||refresh;
+	refresh=objectVerifyRoom(kid,room)||refresh;
 	
 	if (refresh) { /* room map was changed and needs to be refreshed */
 		*room=mapGetRoom(room->level,room->id);
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index 72eba69..fd1d0b8 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -19,7 +19,7 @@
 */
 
 /*
-kid.h: Free Prince : Kid object
+kid.h: Free Prince : Kid and other objects
 \xaf\xaf\xaf\xaf\xaf
  Copyright 2004 Princed Development Team
   Created: 19 Jul 2004
@@ -40,37 +40,36 @@ kid.h: Free Prince : Kid object
 
 #define NEW_KERNEL
 
-static struct {
-	tData* kid[2];
-} kidGfx;
-
-void loadGfx(int storeMirrored) {
-	kidGfx.kid[DIR_LEFT]=resLoad(RES_IMG_ALL_KID);
+void loadGfx(int storeMirrored, tData** gfxCache, unsigned long resId) {
+	gfxCache[DIR_LEFT]=resLoad(resId);
 	if (storeMirrored)
-		kidGfx.kid[DIR_RIGHT]=resLoad(RES_IMG_ALL_KID|RES_MODS_INVERT);
+		gfxCache[DIR_RIGHT]=resLoad(resId|RES_MODS_INVERT);
+	else
+		gfxCache[DIR_RIGHT]=NULL;
 }
 
-void kidFree() {
-	resFree(kidGfx.kid[DIR_LEFT]);
-	resFree(kidGfx.kid[DIR_RIGHT]);
+void objectFree(tData** gfxCache) {
+	resFree(gfxCache[DIR_LEFT]);
+	if (gfxCache[DIR_RIGHT]) resFree(gfxCache[DIR_RIGHT]);
 }
 
-/* TODO: send this function to maps.c */
-tKid kidCreate() {
-	tKid kid;
+/* TODO: make a function in maps.c that calls this one */
+tObject objectCreate(int location, int floor, int direction, int stateId, unsigned long resId,int cacheMirror) {
+	tObject object;
 
-	if (kidGfx.kid[0]==NULL) loadGfx(1);
+	loadGfx(cacheMirror,object.gfxCache,resId);
 
-	kid.location=30;
-	kid.floor=1;
-	kid.direction=DIR_RIGHT;
-	kid.action=createState(stateKidInLevel(1)); /* level 1 */
-	return kid;
+	object.location=location;
+	object.floor=floor;
+	object.direction=direction;
+	object.action=createState(stateId);
+	return object;
 }
 
-int kidVerifyRoom(tKid *kid,tRoom *room) {
+int objectVerifyRoom(tObject *kid,tRoom *room) {
 	/* if the kid is out of the screen we need to change the screen and put
 	 * the kid back again on it
+	 * PRE: tObject *kid is a kid
 	 */
 	
 	int refresh=0;
@@ -109,8 +108,8 @@ int kidVerifyRoom(tKid *kid,tRoom *room) {
 	
 #define kid_getLocation(kid,image) ((kid).location-(outputGetWidth(image)>>1))
 
-void kidDraw(tKid kid) {
-	void* image=kidGfx.kid[kid.direction]->pFrames[stateGetImage(kid)-1];
+void objectDraw(tObject kid) {
+	void* image=kid.gfxCache[kid.direction]->pFrames[stateGetImage(kid)-1];
 	/* TODO: move this -1 to each script frame */
 	outputDrawBitmap(
 		image, 
@@ -119,7 +118,7 @@ void kidDraw(tKid kid) {
 	);
 }
 
-int kidMove(tKid* kid,tKey key,tRoom* room) {
+int objectMove(tObject* kid,tKey key,tRoom* room) {
 	/* advance state and get the flag, then interpret the flag and do the events */
 	short flags;
 	int refresh=0;
@@ -127,9 +126,9 @@ int kidMove(tKid* kid,tKey key,tRoom* room) {
 	
 	flags=stateUpdate(&key,kid,room);
 
-	if (room==NULL) return flags;
+	if (room==NULL) return flags; /* exits if it is not associated to a room */
 	
-	x=kid_getLocation(*kid,kidGfx.kid[kid->direction]->pFrames[stateGetImage(*kid)-1])/TILE_W;
+	x=kid_getLocation(*kid,kid->gfxCache[kid->direction]->pFrames[stateGetImage(*kid)-1])/TILE_W;
 	
 	if (flags&STATES_FLAG_P)
 		refresh=mapPressedTile(
@@ -145,7 +144,7 @@ printf("f era %d. ",kid->floor);
 	if (flags&STATES_FLAG_U)
 		kid->floor--;
 printf("f pasa a ser %d\n",kid->floor);
-	refresh=kidVerifyRoom(kid,room)||refresh;
+	refresh=objectVerifyRoom(kid,room)||refresh;
 	
 	if (refresh) { /* room map was changed and needs to be refreshed */
 		*room=mapGetRoom(room->level,room->id);
diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c
index 8cef3ae..1099178 100644
--- a/FP/src/ker/states.c
+++ b/FP/src/ker/states.c
@@ -87,7 +87,7 @@ tState createState(short stateId) {
 /* Evaluates a condition indexed in the condition table */
 #define DefaultTrue(pointer) if (!pointer) return STATES_CONDRESULT_TRUE
 #define DefaultFalse(pointer) if (!pointer) return STATES_CONDRESULT_TRUE
-int evaluateCondition(int condition,tKey* key, tKid* kid, tRoom* room) {
+int evaluateCondition(int condition,tKey* key, tObject* kid, tRoom* room) {
 	tsCondition c=statesConditionList[condition];
 #define thisTile (kid->location/STATES_STEPS_PER_TILE+13+12*kid->floor)
 #define whereInTile ((kid->direction==DIR_LEFT)?(kid->location%STATES_STEPS_PER_TILE):STATES_STEPS_PER_TILE-(kid->location%STATES_STEPS_PER_TILE))
@@ -168,7 +168,7 @@ int evaluateCondition(int condition,tKey* key, tKid* kid, tRoom* room) {
 }
 
 /* Evaluates all conditions needed for an action and returns true or false */
-int evaluateAction(int currentAction,tKey* key, tKid* kid,tRoom* room) {
+int evaluateAction(int currentAction,tKey* key, tObject* kid,tRoom* room) {
 	int i=statesActionList[currentAction].conditionId;
 	int result;
 	while ((result=evaluateCondition(i,key,kid,room))==STATES_CONDRESULT_TRUE) i++;
@@ -177,7 +177,7 @@ int evaluateAction(int currentAction,tKey* key, tKid* kid,tRoom* room) {
 }
 
 /* Evaluates a state: all conditions for all actions until a true is found and returns the next state id*/
-int evaluateState(int state, tKey* key, tKid* kid, tRoom* room) {
+int evaluateState(int state, tKey* key, tObject* kid, tRoom* room) {
 	int i=state;
 	while (!evaluateAction(i,key,kid,room)) i++;
 	return i;
@@ -187,7 +187,7 @@ int evaluateState(int state, tKey* key, tKid* kid, tRoom* room) {
 
 /* This function should return the image frame and actions to be performed by this call
  * returns the animation number corresponding to this frame */
-short stateUpdate(tKey* key, tKid* kid,tRoom* room) {
+short stateUpdate(tKey* key, tObject* kid,tRoom* room) {
 	tState* current=&(kid->action);
 	/*static float step;
 	static float acumLocation;*/
diff --git a/FP/src/ker/titles.c b/FP/src/ker/titles.c
index 5844710..3a81b13 100644
--- a/FP/src/ker/titles.c
+++ b/FP/src/ker/titles.c
@@ -40,29 +40,94 @@ titles.c: FreePrince : Titles, animation and presentation
 #include "anims.h"
 #include "kid.h"
 
-/* New source */
+typedef struct {
+	tData*        img;
+	unsigned char layer;
+	unsigned short duration;
+	unsigned short x;
+	unsigned short y;
+} titleFixedimg;
 
+/* New source */
 tMenuOption playAnimation(int id) {
-	int totalStates=animStart(id);
 	int qf,qt,qo,i;
 	animFixedimg* f;
 	animState* t;
 	animSound* o;
+	titleFixedimg* fa;
+	tObject* ta;
+	animSound* oa;
 	tKey key=inputCreateKey();
 	tKey nullKey=inputCreateKey();
-
-	tKid* object=(tKid*)malloc(totalStates*sizeof(tKid));
-	for (i=0;i<totalStates;i++) object[i]=kidCreate();
+	int activef=0;
+	int activet=0;
+	/*int activeo=0;*/
+	int totalf,totalt,totalo;
+	tObject* object;
+	
+	animStart(id,&totalf,&totalt,&totalo);
+	fa=(titleFixedimg*)malloc(totalf*sizeof(titleFixedimg));
+	ta=(tObject*)malloc(totalt*sizeof(tObject));
+	oa=(animSound*)malloc(totalo*sizeof(animSound));
+	
 	while (animGetFrame(&qf,&qt,&qo,f,t,o)) {
 		if (inputGetEvent(&key)) {
 			/* key pressed */
 			printf("key pressed\n");
 		} else {
-  		kidMove(object+1,nullKey,NULL);
+			/* create new images/objects/sounds */
+			for (i=0;i<qf;i++) { /*images*/
+				fa[activef].img=resLoad(f[i].res);
+				fa[activef].y=f[i].y;
+				fa[activef].x=f[i].x;
+				fa[activef].layer=f[i].layer;
+				fa[activef].duration=f[i].duration;
+				activef++;
+			}
+			for (i=0;i<qt;i++) { /*objects*/
+				ta[activet]=objectCreate(t[i].location,t[i].floor,DIR_LEFT,t[i].state,t[i].res,t[i].cacheMirror);
+				activet++;
+			}
+/*		TODO: code sounds	
+ *		for (i=0;i<qo;i++) {
+				fa[activeo]=o[i];
+				activeo++;
+			}*/
+
+			outputClearScreen();
+			/* The bottom layer */
+			for (i=0;i<activef;i++) {
+				if (fa[i].layer==ANIMS_LAYERTYPE_BOTTOM)
+					outputDrawBitmap(fa[i].img->pFrames[0], fa[i].x, fa[i].y);
+			}
+			/* move objects */
+			for (i=0;i<activet;i++) {
+				/*TODO: detect exits */
+	  		objectMove(ta+i,nullKey,NULL);
+	  		/*objectDraw(ta+i);*/
+			}
+			/* The top layer */
+			for (i=0;i<activef;i++) {
+				if (fa[i].layer==ANIMS_LAYERTYPE_TOP)
+					outputDrawBitmap(fa[i].img->pFrames[0], fa[i].x, fa[i].y);
+			}
+			outputUpdateScreen();
+
+			/* exited states and caducied backgrounds destruction */
+			for (i=0;i<activef;i++) {
+				if (fa[i].duration) { /* if not 0 (infinite) */
+					fa[i].duration--;
+					if (!fa[i].duration) { /* time is over for this images */
+						activef--;
+						resFree(fa[i].img);
+						fa[i]=fa[activef];
+					}
+				}
+			}	
 		}
 	}
-	/*void kidDraw(tKid kid);*/
-	for (i=0;i<totalStates;i++) kidFree(object[i]);
+	/*void objectDraw(tObject kid);*/
+	for (i=0;i<activef;i++) objectFree(object[i]);
 	free(object);
 	return menuQuit;
 }
diff --git a/FP/src/res/anims.c b/FP/src/res/anims.c
index 30a181e..2f6b384 100644
--- a/FP/src/res/anims.c
+++ b/FP/src/res/anims.c
@@ -54,10 +54,12 @@ static animTable table[]=ANIMS_TABLE;
 static animTable rec;
 static int frame;
 
-int animStart(int animId) {
+void animStart(int animId,int *qf,int *qt,int *qo) {
 	rec=table[animId];
 	frame=0;
-	return rec.stateSize;
+	*qf=rec.fixedimgSize;
+	*qt=rec.stateSize;
+	*qo=rec.soundSize;
 }
 
 int animGetFrame(int* qf,int* qt,int* qo, animFixedimg* f,animState* t, animSound* o) {
diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c
index 2897dc3..3e3114b 100644
--- a/FP/src/res/maps.c
+++ b/FP/src/res/maps.c
@@ -273,7 +273,7 @@ tRoom mapGetRoom(tMap* map, tRoomId roomAux) {
 	return result;
 }
 
-void  mapStart(tMap* map, tKid* kid, tRoomId *roomId, int level) {
+void  mapStart(tMap* map, tObject* kid, tRoomId *roomId, int level) {
 	/* kid->x,y */
 	static char environments[]=MAP_ENVIRONMENTS;
 	*roomId=slevel(start)[0];