git » fp-git.git » commit 1c3e73f

new kernel kid states implementation

author ecalot
2004-10-21 04:48:18 UTC
committer ecalot
2004-10-21 04:48:18 UTC
parent ccd58ee5b90386b03ef06f10f2a4ae17511dfa43

new kernel kid states implementation

FP/src/include/states.h +0 -7
FP/src/include/types.h +6 -0
FP/src/ker/kid.c +16 -0
FP/src/ker/object.c +16 -0

diff --git a/FP/src/include/states.h b/FP/src/include/states.h
index 8dab921..3ade7e0 100644
--- a/FP/src/include/states.h
+++ b/FP/src/include/states.h
@@ -26,13 +26,6 @@ typedef struct {
 	short        animSize; /* number of frames to be shown */
 } tsAction;
 
-/* public object */
-typedef struct { /* The state object: only struct that is not static to the state class */
-	short  frame; /* when zero, animation is released and the next state is taken */
-	short* animation;
-	short  currentState;
-} tState;
-
 /* public functions interface */
 
 /* This function should return the image frame
diff --git a/FP/src/include/types.h b/FP/src/include/types.h
index 450c5df..38b7dda 100644
--- a/FP/src/include/types.h
+++ b/FP/src/include/types.h
@@ -44,6 +44,12 @@ typedef enum {eJustPressed,eNormal,ePressed,eStuck}tPressableAction;
 typedef enum {eNormalGate,eExitGate}tGateType;
 typedef enum {eDrop,eRaise}tPressableType;
 
+typedef struct { /* The state object: only struct that is not static to the state class */
+	short  frame; /* when zero, animation is released and the next state is taken */
+	short* animation;
+	short  currentState;
+} tState;
+
 typedef struct {
 	int time;
 	int frame;
diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c
index a3299e9..338592b 100644
--- a/FP/src/ker/kid.c
+++ b/FP/src/ker/kid.c
@@ -37,7 +37,12 @@ kid.h: Free Prince : Kid object
 #include "maps.h" /* getTile */
 #include <stdio.h> /* NULL */
 
+/*#define NEW_KERNEL*/
+
 static struct {
+#ifdef NEW_KERNEL
+	tData* kid[2];
+#else
 	tData* turning[2];
 	tData* normal[2];
 	tData* couching[2];
@@ -48,9 +53,14 @@ static struct {
 	tData* stoprunning[2];
 	tData* turnrunning[2];
 	tData* jumprunning[2];
+#endif
 } kidGfx;
 
 void loadGfx() {
+#ifdef NEW_KERNEL
+	kidGfx.kid[DIR_LEFT]=resLoad(RES_IMG_KID_ALL);
+	kidGfx.kid[DIR_RIGHT]=resLoad(RES_IMG_KID_ALL|RES_MODS_INVERT);
+#else
 	kidGfx.turning[DIR_LEFT]=resLoad(RES_ANIM_TURNING);
 	kidGfx.turning[DIR_RIGHT]=resLoad(RES_ANIM_TURNING|RES_MODS_INVERT);
 	kidGfx.normal[DIR_LEFT]=resLoad(RES_ANIM_NORMAL);
@@ -71,9 +81,14 @@ void loadGfx() {
 	kidGfx.turnrunning[DIR_RIGHT]=resLoad(RES_ANIM_RUN_TURN|RES_MODS_INVERT);
 	kidGfx.jumprunning[DIR_LEFT]=resLoad(RES_ANIM_JUMPRUN);
 	kidGfx.jumprunning[DIR_RIGHT]=resLoad(RES_ANIM_JUMPRUN|RES_MODS_INVERT);
+#endif
 }
 
 void kidFree() {
+#ifdef NEW_KERNEL
+	resFree(kidGfx.kid[DIR_LEFT]);
+	resFree(kidGfx.kid[DIR_RIGHT]);
+#else
 	resFree(kidGfx.turning[DIR_LEFT]);
 	resFree(kidGfx.turning[DIR_RIGHT]);
 	resFree(kidGfx.normal[DIR_LEFT]);
@@ -94,6 +109,7 @@ void kidFree() {
 	resFree(kidGfx.turnrunning[DIR_RIGHT]);
 	resFree(kidGfx.jumprunning[DIR_LEFT]);
 	resFree(kidGfx.jumprunning[DIR_RIGHT]);
+#endif
 }
 
 /* TODO: send this function to maps.c */
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index a3299e9..338592b 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -37,7 +37,12 @@ kid.h: Free Prince : Kid object
 #include "maps.h" /* getTile */
 #include <stdio.h> /* NULL */
 
+/*#define NEW_KERNEL*/
+
 static struct {
+#ifdef NEW_KERNEL
+	tData* kid[2];
+#else
 	tData* turning[2];
 	tData* normal[2];
 	tData* couching[2];
@@ -48,9 +53,14 @@ static struct {
 	tData* stoprunning[2];
 	tData* turnrunning[2];
 	tData* jumprunning[2];
+#endif
 } kidGfx;
 
 void loadGfx() {
+#ifdef NEW_KERNEL
+	kidGfx.kid[DIR_LEFT]=resLoad(RES_IMG_KID_ALL);
+	kidGfx.kid[DIR_RIGHT]=resLoad(RES_IMG_KID_ALL|RES_MODS_INVERT);
+#else
 	kidGfx.turning[DIR_LEFT]=resLoad(RES_ANIM_TURNING);
 	kidGfx.turning[DIR_RIGHT]=resLoad(RES_ANIM_TURNING|RES_MODS_INVERT);
 	kidGfx.normal[DIR_LEFT]=resLoad(RES_ANIM_NORMAL);
@@ -71,9 +81,14 @@ void loadGfx() {
 	kidGfx.turnrunning[DIR_RIGHT]=resLoad(RES_ANIM_RUN_TURN|RES_MODS_INVERT);
 	kidGfx.jumprunning[DIR_LEFT]=resLoad(RES_ANIM_JUMPRUN);
 	kidGfx.jumprunning[DIR_RIGHT]=resLoad(RES_ANIM_JUMPRUN|RES_MODS_INVERT);
+#endif
 }
 
 void kidFree() {
+#ifdef NEW_KERNEL
+	resFree(kidGfx.kid[DIR_LEFT]);
+	resFree(kidGfx.kid[DIR_RIGHT]);
+#else
 	resFree(kidGfx.turning[DIR_LEFT]);
 	resFree(kidGfx.turning[DIR_RIGHT]);
 	resFree(kidGfx.normal[DIR_LEFT]);
@@ -94,6 +109,7 @@ void kidFree() {
 	resFree(kidGfx.turnrunning[DIR_RIGHT]);
 	resFree(kidGfx.jumprunning[DIR_LEFT]);
 	resFree(kidGfx.jumprunning[DIR_RIGHT]);
+#endif
 }
 
 /* TODO: send this function to maps.c */