| author | ecalot
<ecalot> 2005-01-22 20:46:38 UTC |
| committer | ecalot
<ecalot> 2005-01-22 20:46:38 UTC |
| parent | b820060dc13f07393d67d8dc15607b7ba13dba1b |
| FP/src/conf/awk/tiles_conf_groups.awk | +39 | -4 |
| FP/src/conf/tiles.conf | +3 | -1 |
| FP/src/ker/kid.c | +0 | -2 |
| FP/src/ker/room.c | +2 | -0 |
| FP/src/ker/states.c | +14 | -15 |
| FP/src/res/maps.c | +2 | -0 |
| FP/src/res/tiles.c | +26 | -9 |
diff --git a/FP/src/conf/awk/tiles_conf_groups.awk b/FP/src/conf/awk/tiles_conf_groups.awk index c05319f..d148eb5 100644 --- a/FP/src/conf/awk/tiles_conf_groups.awk +++ b/FP/src/conf/awk/tiles_conf_groups.awk @@ -36,14 +36,28 @@ $0 !~ /^[ ]*(#.*|tile .*|[ ]*)$/ { for (i=1;i<=NF;i++) { group=$i back=0 + info=0 + info2=0 if (group ~ /@/) { split(group,a,"@") - group=a[1] - back=a[2]+1 + if (a[2] ~ /^[0-9]+$/) { + group=a[1] + back=a[2]+1 + } else if (a[2] ~ /^[A-Z][a-z]+$/) { + group=a[1] + info=a[2] + info2=a[3] + } else { + #error + printf("Parsing error in tiles.conf: Syntax error at %s modifier in line %d.\n",a[1],NR)>"/dev/stderr" + exit 50 + } } group=toupper(group) if (!total[group]) total[group]=0 groups[group,total[group]]=tile + infos[group,total[group]]=info + info2s[group,total[group]]=info2 backs[group,total[group]]=back total[group]++; } @@ -52,19 +66,25 @@ $0 !~ /^[ ]*(#.*|tile .*|[ ]*)$/ { END { offset=0 coma="" + infocount=0 printf "#define TILE_GROUP_LIST {" for (group in total) { offsets[group]=offset for (i=0;i<total[group];i++) { if (backs[group,i]) { #if there is a back selected add them printf "%s(unsigned char)(%s+129),%d",coma,groups[group,i],backs[group,i]-1 - coma="," + offset+=2 + } else if (infos[group,i]) { #if there is info selected add them + infocount++ + printf "%s(unsigned char)(%s+65),%d",coma,groups[group,i],infocount + arrinfos[infocount]=infos[group,i] + arrinfo2s[infocount]=info2s[group,i] offset+=2 } else { printf "%s%s+1",coma,groups[group,i] - coma="," offset++ } + coma="," if (offset%5==0) printf("\\\n") } printf ",0" @@ -72,8 +92,23 @@ END { if (offset%5==0) printf("\\\n") } printf "}\n" + #add the TILES_* group defines for (group in offsets) { printf "#define TILES_%s %d\n",group,offsets[group]+32 } + #add the TILES_MACRO_?_* macro defines + printf "\n" + for (i=1;i<=infocount;i++) { + printf "#define TILES_MACRO_1_%d(a) ((t%s*)((a).moreInfo))\n",i,arrinfos[i] + printf "#define TILES_MACRO_2_%d(info) (%s)\n",i,arrinfo2s[i] + printf "#define TILES_MACRO_x_%d(tile) TILES_MACRO_2_%d(TILES_MACRO_1_%d(tile))\n",i,i,i + } + #add the TILES_MACROS_CASE define + printf "\n" + printf "#define TILES_MACROS_CASE(type,tile) switch (type) {\\\n" + for (i=1;i<=infocount;i++) { + printf "\tcase %d:return TILES_MACRO_x_%d(tile);\\\n",i,i + } + printf "\tdefault:return 0;\\\n}\n\n" } diff --git a/FP/src/conf/tiles.conf b/FP/src/conf/tiles.conf index 680fe42..7d34b3f 100644 --- a/FP/src/conf/tiles.conf +++ b/FP/src/conf/tiles.conf @@ -36,6 +36,7 @@ walkable floor brickf1@0 brickf2@1 tile SPIKES 2 spike walkable dangerous spikes chopper_spike +spikeup@Danger@((2<info->frame)&&(info->frame<5)) tile PILLAR 3 none walkable pillar @@ -77,9 +78,10 @@ walkable dangerous pressable raise tile EXIT_LEFT 16 none gates walkable +exitdoor@Gate@info->frame==0 tile EXIT_RIGHT 17 none -walkable exitdoor +walkable tile CHOPPER 18 chomp chopper floor walkable chopper_spike diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c index 198502a..50b981a 100644 --- a/FP/src/ker/kid.c +++ b/FP/src/ker/kid.c @@ -83,7 +83,6 @@ int kidMove(tObject* kid,short flags,tRoom* room) { if (flags&STATES_FLAG_P) refresh=roomPress(room,kid); -printf("f era %d. ",kid->floor); if (flags&STATES_FLAG_F) { kid->floor++; roomKidChangedFloor(room,kid); @@ -92,7 +91,6 @@ printf("f era %d. ",kid->floor); kid->floor--; roomKidChangedFloor(room,kid); } -printf("f pasa a ser %d\n",kid->floor); return kidVerifyRoom(kid,room,refresh); } diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c index 3b66da3..680d381 100644 --- a/FP/src/ker/room.c +++ b/FP/src/ker/room.c @@ -500,7 +500,9 @@ int roomPress(tRoom* room, tObject* obj) { } /* Loose tiles */ +#ifdef DEBUGROOM printf("s=%d x=%d y=%d\n",s,x,y); +#endif if (isIn(tile,TILE_LOOSE)) { map->fore[(s-1)*30+(x-1)+(y-1)*10]=TILE_EMPTY; refresh=1; /* room changed, refresh it */ diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c index ad148d1..5cf2012 100644 --- a/FP/src/ker/states.c +++ b/FP/src/ker/states.c @@ -36,6 +36,7 @@ states.c: FreePrince : State object #include <stdio.h> /* For debug purposes */ #include "object.h" /* DIR_LEFT DIR_RIGHT */ +#ifdef DEBUGSTATES void debugShowFlag(short optionflag) { if (optionflag&STATES_FLAG_F) printf("Falling "); if (optionflag&STATES_FLAG_P) printf("PressFloor "); @@ -43,6 +44,7 @@ void debugShowFlag(short optionflag) { if (optionflag&STATES_FLAG_S) printf("Sound"); printf("\n"); } +#endif #define STATES_STEPS_PER_TILE TILE_W /* Private static state graph */ @@ -60,7 +62,9 @@ void stateGetAnimation(int action,tState *state/*short *frames,short** flags,flo state->animation=(short*)malloc(sizeof(short)*i); state->steps=(short*)malloc(sizeof(short)*i); state->flags=(short*)malloc(sizeof(short)*i); +#ifdef DEBUGSTATES printf("* Animsize=%d Animstart=%d. (new animation allocated) Next:\n",i,a->animStart); +#endif state->step=(float)(totaloffset)/(float)(i); /* this is the full step to be used in case a non step walk is set TODO: delete this system */ while (i--) { (state->animation)[i]=*(j++); /* the first short is the frame */ @@ -200,10 +204,12 @@ short stateUpdate(tKey* key, tObject* kid,tRoom* room) { flags =current->flags [current->frame]; steps =current->steps [current->frame]; - /* BEGIN DEBUG */ + /* BEGIN DEBUGSTATES */ +#ifdef DEBUGSTATES printf("stateUpdate: animation=%d steps=%d ",current->image,steps); debugShowFlag(flags); - /* END DEBUG */ +#endif + /* END DEBUGSTATES */ if (!current->frame) { int action; @@ -218,7 +224,9 @@ short stateUpdate(tKey* key, tObject* kid,tRoom* room) { stateGetAnimation(action,current); /* Remember the state where we are now */ current->currentState=statesActionList[action].nextStateId; +#ifdef DEBUGSTATES printf("NEW STATE: action=%d next=%d\n",action,current->currentState); +#endif /* Move the kid (turn+traslate) */ switch(statesActionList[action].moveType) { case STATES_MOVETYPES_ABSOLUTEONSTART: @@ -256,13 +264,17 @@ short stateUpdate(tKey* key, tObject* kid,tRoom* room) { to=alternate(j,i); if (j%2) { /* the first frames are ok, so I'll fix the last frames */ +#ifdef DEBUGSTATES printf("from=%d to=%d ok\n",from,to); +#endif current->animation[to]=current->animation[from]; current->flags[to]=current->flags[from]; current->steps[to]=current->steps[from]; } } +#ifdef DEBUGSTATES printf("total frames=%d number of frames to be used=%d. wanted movement=%d movement to be performed=%d\n",current->frame,i,statesActionList[action].moveOffset,accumulate); +#endif current->frame=i; /* now the last frames are moved, crop the animation */ break; } @@ -283,19 +295,6 @@ short stateUpdate(tKey* key, tObject* kid,tRoom* room) { kid->location+=(kid->direction==DIR_LEFT)?-steps:steps; -/* - { - int jj; - for (jj=0;jj<5;jj++) { - - printf("%d=>",alternate(jj,10)); - printf("%d ",alternate(jj,5)); - } - printf("\n"); - } -*/ - - if (current->frame==1&¤t->currentState<0) return current->currentState; /* if last frame of the last state, return exit code */ return flags; } diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index 23d79e0..d9914c9 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -382,7 +382,9 @@ void mapMove(tMap* map) { } /* check out and update all the spikes and choppers */ +#ifdef DEBUGMAPS printf("chopper act=%d tim=%d fra=%d\n",map->dangers[i].time,map->dangers[i].action,map->dangers[i].frame); +#endif for (i=0;i<slevel(totalDangers);i++) { switch (map->dangers[i].action) { case eSpiUp: diff --git a/FP/src/res/tiles.c b/FP/src/res/tiles.c index 5b649d3..b8f3ef7 100644 --- a/FP/src/res/tiles.c +++ b/FP/src/res/tiles.c @@ -31,29 +31,46 @@ tiles.c: FreePrince : Tile functions */ #include "tiles.h" +#include <stdio.h> /* NULL */ -int isInGroup(unsigned char tile,unsigned char backtile,short group) { +int evaluate(tTile tile,int type) { /* type is the number in the modifier */ + if (!tile.moreInfo) { + printf("Tile Error: trying to use a tile that hasn't extra information\n"); + return 0; + } + TILES_MACROS_CASE(type,tile) +} + +int isIn(tTile tile,short group) { static unsigned char tileList[]=TILE_GROUP_LIST; unsigned char* i; int docontinue; - tile=tile&0x1F; /* get the last 5 bits and clear the beginning */ - if (group<32) return (tile==group); + tile.code=tile.code&0x1F; /* get the last 5 bits and clear the beginning */ + if (group<32) return (tile.code==group); i=tileList+(group-32); - tile++; + tile.code++; do { docontinue=0; - while ((*i)&&(((*i)&0x7f)!=tile)) i+=((*i)&0x80)?2:1; - if ((*i)&0x80) { + while ((*i)&&(((*i)&0x3f)!=tile.code)) i+=((*i)&0xC0)?2:1; + if ((*i)&0x80) { /* compare against the back */ i++; - if ((*i)==(backtile+1)) return 1; + if ((*i)==(tile.back+1)) return 1; + docontinue=1; + } else if ((*i)&0x40) { /* compare against the function */ + i++; + if (evaluate(tile,*i)) return 1; docontinue=1; } } while (docontinue); return *i; /* returns non-zero if true and zero if false */ } -int isIn(tTile tile,short group) { - return isInGroup(tile.code,tile.back,group); +int isInGroup(unsigned char fore,unsigned char back,short group) { + tTile t; + t.code=fore; + t.back=back; + t.moreInfo=NULL; + return isIn(t,group); }