git » fp-git.git » commit 04ca938

Added getAnimation function to states.c and the rule to the makefile

author ecalot
2004-10-17 06:03:58 UTC
committer ecalot
2004-10-17 06:03:58 UTC
parent 40596d3fe9982deb3195efe0ba7d1135da4c7dce

Added getAnimation function to states.c and the rule to the makefile

FP/src/Makefile +1 -1
FP/src/ker/states.c +14 -3

diff --git a/FP/src/Makefile b/FP/src/Makefile
index 4dc6331..72fd49c 100644
--- a/FP/src/Makefile
+++ b/FP/src/Makefile
@@ -50,7 +50,7 @@ LINKERRELEASE =
 #Binary code files
 OBJFILES      = main.o kernel.o resources.o dat.o disk.o compress.o \
                 output.o maps.o config.o room.o titles.o \
-                input.o kid.o
+                input.o kid.o states.o
 EXEFILE       = bin/freeprince
 
 GENERATEDRESHEADERS = include/res_conf_parts.h include/res_conf_files.h\
diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c
index 80b8753..c828c74 100644
--- a/FP/src/ker/states.c
+++ b/FP/src/ker/states.c
@@ -1,12 +1,23 @@
 #include "states.h"
+#include <stdlib.h>
 
-
-short* stateGetAnimation(int action,short* frames);
-
+/* Private static state graph */
 static tsAction statesActionList[]=STATES_ACTIONS;
 static short statesAnimationList[]=STATES_ANIMATIONS;
 static tsCondition statesConditionList[]=STATES_CONDITIONS;
 
+short* stateGetAnimation(int action,short *frames) {
+	short* result;
+	tsAction* a=statesActionList+action;
+	short i=a->animSize;
+	short* j=statesAnimationList+a->animStart;
+	/* TODO: depending on relative and absolute crop the middle frames */
+	*frames=i;
+	result=(short*)malloc(sizeof(short)*i);
+	while (i--) result[i]=*(j++);
+	return result;
+}
+
 /* public functions interface */
 tState createState(int level) {
 	tState start;