git » fp-git.git » commit 6bdfeb6

changed some comments

author ecalot
2005-05-26 09:39:07 UTC
committer ecalot
2005-05-26 09:39:07 UTC
parent 1c270276c472ca363f4aa768336e7daa6c697035

changed some comments

FP/src/ker/kernel.c +9 -8
FP/src/ker/object.c +10 -9
FP/src/ker/room.c +25 -6
FP/src/ker/states.c +10 -7
FP/src/ker/titles.c +1 -21

diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c
index f758f8c..897da25 100644
--- a/FP/src/ker/kernel.c
+++ b/FP/src/ker/kernel.c
@@ -25,7 +25,7 @@ kernel.c: FreePrince : Main Kernel
   Created: 16 Jun 2004
 
   Authores: Diego Essaya <dessaya.cod@princed.com.ar>
-	          Enrique Calot <ecalot.cod@princed.com.ar>
+            Enrique Calot <ecalot.cod@princed.com.ar>
 
  Note:
   DO NOT remove this copyright notice
@@ -33,15 +33,15 @@ kernel.c: FreePrince : Main Kernel
 
 #include <stdlib.h>
 #include <stdio.h>
-#include "kernel.h"
-#include "resources.h"
-#include "output.h"
 #include "input.h"
-#include "titles.h"
-#include "states.h" /* stateKidInLevel */
+#include "kernel.h"
+#include "maps.h"
 #include "object.h"
+#include "output.h"
+#include "resources.h"
 #include "room.h"
-#include "maps.h"
+#include "states.h" /* stateKidInLevel */
+#include "titles.h"
 
 /*
  * Main game control function
@@ -102,6 +102,7 @@ int playgame(int optionflag,int level) {
 					timeDead++;	
 					kidKillHim(&kid);
 				}
+				/* hardcoded blinking message */
 				if (timeDead==20) outputDrawMessage(120,"Press Button to Continue");
 				if (timeDead==160) outputDrawMessage(10,"Press Button to Continue");
 				if (timeDead==180) outputDrawMessage(10,"Press Button to Continue");
@@ -233,7 +234,7 @@ int kernel(int optionflag,int level) {
 		}
 	} while(!quit);
 
-	objectFree(&kid); /*TODO: exiting from the story will cause a game crash because this object wasn't allocated*/
+	objectFree(&kid); /*TODO: exiting from the story will cause a game crash because this object wasn't allocated */
 	inputStopTimer();
 	outputStop();
 	return 0;
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index a580bad..a6e8a52 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -32,7 +32,7 @@ object.h: Free Prince : Objects
 
 #include "kid.h"
 #include "output.h"
-#include "resources.h" /* resLoad/resFree */
+#include "resources.h" /* resLoad resFree */
 #include "maps.h" /* mapGetRoom getTile */
 #include <stdio.h> /* NULL */
 #include "states.h"
@@ -86,6 +86,8 @@ void objectDraw(tObject* object) {
 	);
 }
 
+/* event triggered when an object is moved */
+
 int objectMove(tObject* object,tKey key,tRoom* room) {
 	/* advance state and get the flag, then interpret the flag and do the events */
 	short flags;
@@ -93,18 +95,17 @@ int objectMove(tObject* object,tKey key,tRoom* room) {
 	int x;
 	int y;
 	tTile tile;
-	
+
 	flags=stateUpdate(&key,object,room);
 
 	if (room==NULL) return flags; /* exits if it is not associated to a room */
 
-	
 	/* a static variable type in the tObject determinates what object is it about.
 	 * This is to simulate polymorphism.
 	 * call a function that performs all the actions knowing the room,
 	 * the object and the flags. Returns refresh.
 	 */
-	
+
 	switch (object->type) {
 		case oKid:
 			/* Move the kid */
@@ -112,7 +113,7 @@ int objectMove(tObject* object,tKey key,tRoom* room) {
 			/* Calculate the new positions */
 			x=object->location/TILE_W;
 			y=object->floor;
-			
+
 			if (refresh) *room=mapGetRoom(room->level,room->id);
 			refresh=0;
 			tile=roomGetTile(room,x+1,y+1);
@@ -125,7 +126,7 @@ int objectMove(tObject* object,tKey key,tRoom* room) {
 				      stateUpdate(NULL,object,room); /* move again the to the interrupted state */
 				flags=stateUpdate(NULL,object,room); /* move again to the absoluteOnStart state */
 			}
-			
+
 			/* Check if the object must fall down */
 			if (flags&STATES_FLAG_P) {
 				if (!isIn(tile,TILES_WALKABLE)) { /* INTERRUPTION */
@@ -157,10 +158,10 @@ int objectMove(tObject* object,tKey key,tRoom* room) {
 			refresh=0;
 			break;
 	}
-	
-	if (refresh) { /* room map was changed and needs to be refreshed */
+
+	if (refresh) /* room map was changed and needs to be refreshed */
 		*room=mapGetRoom(room->level,room->id);
-	}
+
 	return flags;
 }
 
diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c
index 3a975b1..d9875af 100644
--- a/FP/src/ker/room.c
+++ b/FP/src/ker/room.c
@@ -135,7 +135,7 @@ int wallGetCase(tTile left, tTile tile, tTile right) {
 #define wallCase(a) (cases==(a))
 
 /*
- * Drawing functions
+ * Hardcoded Drawing functions
  */
 
 #define drawAll(x,y,a) outputDrawBitmap(roomGfx.environment->pFrames[a],(x),(y))
@@ -279,6 +279,11 @@ void drawChopper(int x, int y, int frame, tChopperLayer layer) {
 
 /* End of special drawings */
 
+/*
+ * Those are the three hook functions:
+ *  hook functions are a layer between the drawing loop and the generated headers
+ */
+
 /* main panel block */
 void drawBackPanel(tRoom* room,int x, int y) {
 	tTile tile=roomGetTile(room,x,y);
@@ -348,6 +353,8 @@ int roomPress(tRoom* room, tObject* obj) {
 	 * returns 0 if the room didn't change, 1 if it did
 	 */
 
+	/* Hardcoded behaviors activated when the kid presses a floor */
+				
 	int x=(obj->location/TILE_W)+1;
 	int y=obj->floor+1;
 	tTile tile=roomGetTile(room,x,y);
@@ -357,7 +364,7 @@ int roomPress(tRoom* room, tObject* obj) {
 	enum {border,nearborder,nearbordernotlooking,middle} where;
 	int i;
 
-	/* buttons */
+	/* Hardcoded buttons behavior */
 	if (isIn(tile,TILES_PRESSABLE)) {
 		tEvent* event;
 		((tPressable*)tile.moreInfo)->action=eJustPressed;
@@ -371,14 +378,14 @@ int roomPress(tRoom* room, tObject* obj) {
 		} while	((event++)->triggerNext);
 	}
 
-	/* Loose tiles */
+	/* Loose tiles behavior */
 #ifdef DEBUGROOM
 	printf("s=%d x=%d y=%d\n",s,x,y);
 #endif
   if (isIn(tile,TILES_LOOSENORMAL)) 
 		touchLoose(tile);
 	
-	/* spikes */
+	/* Hardcoded spikes behavior */
 	/* there are 7 possibilities to be */
 #define WHERE_NEAR 6
 #define WHERE_IN 3
@@ -402,12 +409,21 @@ int roomPress(tRoom* room, tObject* obj) {
 			/* spikes left in this floor */
 			tDanger* danger=aux.moreInfo;
 			danger->action=eSpiUp;
-		} else if ((y<3)&&isIn(roomGetTile(room,x+i,y),TILE_EMPTY)&&isIn(aux=roomGetTile(room,x+i,y+1),TILES_SPIKES)) {
+		} else if (
+				(y<3) &&
+				isIn(roomGetTile(room,x+i,y),TILE_EMPTY) &&
+				isIn(aux=roomGetTile(room,x+i,y+1),TILES_SPIKES)
+			) {
 			/* spikes left in the lower floor, there is
 			 * a space so you can fall down */
 			tDanger* danger=aux.moreInfo;
 			danger->action=eSpiUp;
-		} else if ((y<2)&&isIn(roomGetTile(room,x+i,y),TILE_EMPTY)&&isIn(roomGetTile(room,x+i,y+1),TILE_EMPTY)&&isIn(aux=roomGetTile(room,x+i,y+2),TILES_SPIKES)) {
+		} else if (
+				(y<2) &&
+				isIn(roomGetTile(room,x+i,y),TILE_EMPTY) &&
+				isIn(roomGetTile(room,x+i,y+1),TILE_EMPTY) &&
+				isIn(aux=roomGetTile(room,x+i,y+2),TILES_SPIKES)
+			) {
 			/* spikes left in the 2 level lower floor, there are
 			 * spaces so you can fall down */
 			tDanger* danger=aux.moreInfo;
@@ -420,6 +436,8 @@ int roomPress(tRoom* room, tObject* obj) {
 }
 
 void roomKidChangedFloor(tRoom* room, tObject* kid) {
+	/* Hardcoded behaviors activated when the floor changes */
+				
 	/* Choppers */
 	tTile aux;
 	int i,j;
@@ -427,6 +445,7 @@ void roomKidChangedFloor(tRoom* room, tObject* kid) {
 #ifdef ROOMDEBUG
 	printf("kid had changed the floor. Guards and choppers may be allerted.\n");
 #endif
+	/* Hardcoded chomper behavior */
 	for (j=1;j<4;j++) {
 		for (i=1;i<10;i++) {
 			if (isIn((aux=roomGetTile(room,i,j)),TILE_CHOPPER)) {
diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c
index 7eda73a..f79c896 100644
--- a/FP/src/ker/states.c
+++ b/FP/src/ker/states.c
@@ -25,19 +25,19 @@ states.c: FreePrince : State object
   Created: 16 Oct 2004
 
   Authors:  Enrique Calot <ecalot.cod@princed.com.ar>
-	    Rodrigo Campos Catelin <rodrigocc@gmail.com>
+            Rodrigo Campos Catelin <rodrigocc@gmail.com>
  Note:
   DO NOT remove this copyright notice
 */
 
 #include "states.h"
-#include <stdlib.h>
-#include "tiles.h" /* isIn & groups */
-#include <stdio.h> /* For debug purposes */
+#include <stdlib.h> /* malloc free */
+#include "tiles.h" /* isIn "group definitions" */
 #include "object.h" /* DIR_LEFT DIR_RIGHT */
 #include "room.h" /* getTile */
 
 #ifdef DEBUGSTATES
+#include <stdio.h> /* For debug purposes */
 void debugShowFlag(short optionflag) {
 	if (optionflag&STATES_FLAG_F) printf("Falling ");
 	if (optionflag&STATES_FLAG_P) printf("PressFloor ");
@@ -53,7 +53,8 @@ static tsAction statesActionList[]=STATES_ACTIONS;
 static short statesAnimationList[]=STATES_ANIMATIONS;
 static tsCondition statesConditionList[]=STATES_CONDITIONS;
 
-void state_GetAnimation(int action,tState *state/*short *frames,short** flags,float* offsets*/) {
+void state_GetAnimation(int action,tState *state) {
+	/* TODO: check this function, it may not work in 64 bits architectures*/
 	tsAction* a=statesActionList+action;
 	short i=a->animSize;
 	short* j=statesAnimationList+(a->animStart*4);
@@ -120,7 +121,7 @@ void stateReset(tState* state, short stateId) {
 
 #define statesCondRet(a) return (a)?STATES_CONDRESULT_TRUE:STATES_CONDRESULT_FALSE
 
-/* Memory interpreter */
+/* Memory structure interpreter */
 int evaluateCondition(int condition,tKey* key, tObject* kid, tRoom* room) {
 	tsCondition c=statesConditionList[condition];
 	switch(c.type) {
@@ -221,6 +222,7 @@ int evaluateState(int state, tKey* key, tObject* 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, tObject* kid,tRoom* room) {
+	/* TODO: check this function, it may not work in 64 bits architectures*/
 	tState* current=&(kid->action);
 	/*static float step;
 	static float acumLocation;*/
@@ -336,7 +338,8 @@ short stateUpdate(tKey* key, tObject* kid,tRoom* room) {
 	
 	kid->location+=(kid->direction==DIR_LEFT)?-steps:steps;
 
-	if (current->frame==1&&current->currentState<0) return current->currentState; /* if last frame of the last state, return exit code */
+	if ((current->frame==1) && (current->currentState<0))
+		return current->currentState; /* if this is the last frame of the last state, return exit code */
 	return flags;
 }
 
diff --git a/FP/src/ker/titles.c b/FP/src/ker/titles.c
index c2ad675..3732927 100644
--- a/FP/src/ker/titles.c
+++ b/FP/src/ker/titles.c
@@ -40,6 +40,7 @@ titles.c: FreePrince : Titles, animation and presentation
 #include "anims.h"
 #include "object.h"
 
+/* private structures */
 typedef struct {
 	tData*        img;
 	unsigned char layer;
@@ -181,27 +182,6 @@ tMenuOption playAnimation(int id) {
 	return menuQuit;
 }
 
-/* Old source */
-#if 0
-tMenuOption sleep(int ticks) {
-	/* Wait ticks or a key is pressed if an action is thrown process it */
-	tKey key=inputCreateKey();
-	while (ticks) {
-		ticks=inputDelay(&key,ticks);
-		if (
-			/* there are ticks remaining (a non-temporal action was thrown) */
-			ticks &&
-	 		/* there is an action */
-			key.actionPerformed!=none &&
-			/* the action wasn't control key */
-			!(inputGetCtrl(key.status) && key.actionPerformed==other)
-			) 
-			return getAction(key); /* return the results of this action */ 
-	}
-	return menuNone;
-}
-#endif
-
 tMenuOption showTitles() {
 /* Show the titles animation
  * returns 0 if the user has finished the animations with quit