| author | ecalot
<ecalot> 2005-01-13 00:11:08 UTC |
| committer | ecalot
<ecalot> 2005-01-13 00:11:08 UTC |
| parent | bf20590c97f06c8678f23f2b96a20d401a77a706 |
| FP/src/Makefile | +1 | -1 |
| FP/src/conf/awk/states_conf_static.awk | +2 | -2 |
| FP/src/conf/awk/tiles_conf_groups.awk | +4 | -3 |
| FP/src/conf/awk/tiles_conf_types.awk | +1 | -1 |
| FP/src/conf/resources.conf | +2 | -3 |
| FP/src/conf/tiles.conf | +43 | -3 |
| FP/src/include/map_defs.h | +2 | -2 |
| FP/src/include/tiles.h | +2 | -0 |
| FP/src/include/types.h | +1 | -15 |
| FP/src/ker/room.c | +82 | -137 |
| FP/src/ker/titles.c | +55 | -56 |
| FP/src/res/maps.c | +11 | -10 |
| FP/src/res/tiles.c | +5 | -1 |
| stuff/FP-Attic/states_conf_properties.awk | +1 | -1 |
diff --git a/FP/src/Makefile b/FP/src/Makefile index 27a0d7a..5633573 100644 --- a/FP/src/Makefile +++ b/FP/src/Makefile @@ -155,7 +155,7 @@ kernel.o: ker/kernel.c include/kernel.h include/resources.h\ $(CC) -c ker/kernel.c $(OPTIONS) room.o: ker/room.c include/room.h include/resources.h include/res_conf.h\ - include/walls_conf.h + include/walls_conf.h $(GENERATEDTILHEADERS) $(INFO) Compiling kernel room object... $(CC) -c ker/room.c $(OPTIONS) diff --git a/FP/src/conf/awk/states_conf_static.awk b/FP/src/conf/awk/states_conf_static.awk index 14ff270..2a73e6b 100644 --- a/FP/src/conf/awk/states_conf_static.awk +++ b/FP/src/conf/awk/states_conf_static.awk @@ -82,9 +82,9 @@ BEGIN { if ($2!=sprintf("%d",$2)) { #if (1) { #defines[$2]) { if ($1~/^Map/) { - result=sprintf("TG_%s",$2,0) + result=sprintf("TILES_%s",toupper($2),0) } else { - result=sprintf("STATES_COND_%s",$2,0) + result=sprintf("STATES_COND_%s",toupper($2),0) } #} else { # diff --git a/FP/src/conf/awk/tiles_conf_groups.awk b/FP/src/conf/awk/tiles_conf_groups.awk index 3fd6f3d..947878e 100644 --- a/FP/src/conf/awk/tiles_conf_groups.awk +++ b/FP/src/conf/awk/tiles_conf_groups.awk @@ -29,7 +29,7 @@ # /^[ ]*tile .*$/ { - tile=sprintf("T_%s",$2) + tile=sprintf("TILE_%s",$2) } $0 !~ /^[ ]*(#.*|tile .*|[ ]*)$/ { @@ -41,6 +41,7 @@ $0 !~ /^[ ]*(#.*|tile .*|[ ]*)$/ { group=a[1] back=a[2]+1 } + group=toupper(group) if (!total[group]) total[group]=0 groups[group,total[group]]=tile backs[group,total[group]]=back @@ -51,7 +52,7 @@ $0 !~ /^[ ]*(#.*|tile .*|[ ]*)$/ { END { offset=0 coma="" - printf "#define TILES_GROUP_LIST {" + printf "#define TILE_GROUP_LIST {" for (group in total) { offsets[group]=offset for (i=0;i<total[group];i++) { @@ -72,7 +73,7 @@ END { } printf "}\n" for (group in offsets) { - printf "#define TG_%s %d\n",group,offsets[group] + printf "#define TILES_%s %d\n",group,offsets[group] } } diff --git a/FP/src/conf/awk/tiles_conf_types.awk b/FP/src/conf/awk/tiles_conf_types.awk index 67cd7a7..0cb76ce 100644 --- a/FP/src/conf/awk/tiles_conf_types.awk +++ b/FP/src/conf/awk/tiles_conf_types.awk @@ -35,6 +35,6 @@ b="" i=9-length($4) while(i--) b=sprintf(" %s",b) - printf ("#define T_%s 0x%02x %s /* %2d %s%s */\n",$2,$3,a,$3,$4,b) + printf ("#define TILE_%s 0x%02x %s /* %2d %s%s */\n",toupper($2),$3,a,$3,$4,b) } diff --git a/FP/src/conf/resources.conf b/FP/src/conf/resources.conf index 54ea493..a067820 100644 --- a/FP/src/conf/resources.conf +++ b/FP/src/conf/resources.conf @@ -58,12 +58,12 @@ IMG_PRINCESS_PILLAR IMG PV 950 952 IMG_PRINCESS_CLOCK IMG PV 950 953-962 IMG_PRINCESS_BED IMG PV 980 981 IMG_JAFFAR IMG PV 850-888 -IMG_MAIN_BACKGROUND IMG TITLES 50-51 +IMG_MAIN_BACKGROUND IMG TITLES 50 51 IMG_MAIN_PRESENTS IMG TITLES 50 52 IMG_MAIN_AUTHOR IMG TITLES 50 53 IMG_MAIN_GAME_NAME IMG TITLES 50 54 IMG_MAIN_COPYRIGHT IMG TITLES 50 55 -IMG_TEXT_BACKGROUND IMG TITLES 40-41 +IMG_TEXT_BACKGROUND IMG TITLES 50 41 IMG_TEXT_IN_THE_ABSENSE IMG TITLES 42 IMG_TEXT_MARRY_JAFFAR IMG TITLES 43 IMG_TEXT_THE_TYRANT IMG TITLES 44 @@ -86,7 +86,6 @@ IMG_ENV_DUNGEON IMG DUNGEON 200 232 233 234 235 236 237 238 239 240 241 242 IMG_ENV_PALACE IMG PALACE 200 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 269 270 271 272 273 274 285 292 293 294 295 296 297 298 299 300 324 325 326 344 346 347 348 349 350 351 351 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 1230 1231 1286 1287 1288 1289 1290 1291 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 - #sounds SND_MIDI_TITLES SND PCSOUND+1 1 diff --git a/FP/src/conf/tiles.conf b/FP/src/conf/tiles.conf index f97cd4d..48b727a 100644 --- a/FP/src/conf/tiles.conf +++ b/FP/src/conf/tiles.conf @@ -32,32 +32,54 @@ tile EMPTY 0 free dangerous space tile FLOOR 1 free walkable +floor + tile SPIKES 2 spike -walkable dangerous +walkable dangerous spikes + tile PILLAR 3 none +pillar tile GATE 4 gate -gates block@1 +door +gates block@1 gateFrame tile BTN_STUCK 5 none walkable + tile BTN_DROP 6 event walkable +pressable + tile TAPESTRY 7 tapest tile BP_BOTTOM 8 none walkable + tile BP_TOP 9 none tile POTION 10 potion +potion +floor + tile LOOSE 11 none +floor walkable + tile TAPESTRY_TOP 12 ttop +gateFrame + tile MIRROR 13 none walkable + tile DEBRIS 14 none +brokenTile walkable + tile BTN_RAISE 15 event walkable dangerous +pressable +raise + tile EXIT_LEFT 16 none gates @@ -65,17 +87,35 @@ tile EXIT_RIGHT 17 none exitdoor tile CHOPPER 18 chomp +chopper +floor + tile TORCH 19 none +floor +torch + tile WALL 20 wall -block +block wall + tile SKELETON 21 none +skeleton + tile SWORD 22 none +sword +floor + tile BALCONY_LEFT 23 none tile BALCONY_RIGHT 24 none tile LATTICE_PILLAR 25 none +pillar + tile LATTICE_SUPPORT 26 none tile LATTICE_SMALL 27 none tile LATTICE_LEFT 28 none tile LATTICE_RIGHT 29 none tile TORCH_DEBRIS 30 none +torch brokenTile + tile NULL 31 none + + diff --git a/FP/src/include/map_defs.h b/FP/src/include/map_defs.h index f77c436..59ce7d2 100644 --- a/FP/src/include/map_defs.h +++ b/FP/src/include/map_defs.h @@ -140,7 +140,7 @@ Len Offs BlockName & Description */ #define MAP_B_NONE 0 -#define MAP_F_WALL T_WALL -#define MAP_F_FREE T_EMPTY +#define MAP_F_WALL TILE_WALL +#define MAP_F_FREE TILE_EMPTY #endif diff --git a/FP/src/include/tiles.h b/FP/src/include/tiles.h index e1d6499..df73502 100644 --- a/FP/src/include/tiles.h +++ b/FP/src/include/tiles.h @@ -33,9 +33,11 @@ tiles.h: FreePrince : Tile functions #ifndef _TILES_H_ #define _TILES_H_ +#include "types.h" #include "tiles_conf.h" int isInGroup(unsigned char tile,unsigned char backtile,short group); +int isIn(tTile tile,short group); #endif diff --git a/FP/src/include/types.h b/FP/src/include/types.h index 1ad2879..526ddb0 100644 --- a/FP/src/include/types.h +++ b/FP/src/include/types.h @@ -106,27 +106,13 @@ typedef struct { int block; /* Graphical arributes */ - int hasTorch; - int hasGateFrame; - int hasSkeleton; - int hasChopper; int hasBigPillar; int isExit; - int isRaise; - int isGate; void* moreInfo; int bricks; - int isPressable; - int hasSpikes; - int hasPotion; - int hasPillar; - int hasFloor; - int hasBrokenTile; - int isWall; - int hasSword; tModId back; - char code; + unsigned char code; } tTile; typedef struct { diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c index 87505a0..8710db5 100644 --- a/FP/src/ker/room.c +++ b/FP/src/ker/room.c @@ -36,6 +36,7 @@ room.c: FreePrince : Room and Tile Object #include "resources.h" #include "output.h" #include "room.h" +#include "tiles.h" #include "maps.h" #include "walls.h" @@ -82,144 +83,88 @@ tTile roomGetTile(tRoom* room,int x, int y) { result.code=fore&0x1F; switch (result.code) { /* TODO: use the tiles library */ - case T_GATE: - case T_EXIT_LEFT: + case TILE_GATE: + case TILE_EXIT_LEFT: roomId=room->id; if (y==0) roomId=room->links[eUp]; if (x==0) roomId=room->links[eLeft]; if (y==4) roomId=room->links[eDown]; if (x==11)roomId=room->links[eRight]; - result.hasGateFrame=(result.code==T_GATE); result.bricks=0; - result.hasPotion=0; - result.hasPillar=0; result.hasBigPillar=0; - result.isGate=(result.code==T_GATE); if (roomId<24) result.moreInfo=room->level->screenGates[roomId-1][result.back]; result.walkable=1; - result.hasChopper=0; - result.isExit=(result.code==T_EXIT_LEFT)?1:((result.code==T_EXIT_RIGHT)?2:0); + result.isExit=(result.code==TILE_EXIT_LEFT)?1:((result.code==TILE_EXIT_RIGHT)?2:0); result.block=0; - result.isPressable=0; - result.hasSkeleton=0; - result.isRaise=0; - result.hasSpikes=0; - result.hasTorch=0; - result.hasFloor=0; - result.hasBrokenTile=0; - result.isWall=0; - result.hasSword=0; break; - case T_BTN_RAISE: - case T_BTN_DROP: + case TILE_BTN_RAISE: + case TILE_BTN_DROP: roomId=room->id; if (y==0) roomId=room->links[eUp]; /*TODO: validate corners */ if (x==0) roomId=room->links[eLeft]; if (y==4) roomId=room->links[eDown]; if (x==11)roomId=room->links[eRight]; - result.hasGateFrame=0; result.bricks=0; - result.hasPillar=0; result.hasBigPillar=0; - result.hasPotion=0; - result.isGate=0; result.walkable=1; /* the case that a button is in tile 0 should never happen, but we'll care about it just in case */ if (roomId<24) result.moreInfo=room->level->screenPressables[roomId-1][result.back]; - result.hasChopper=0; result.isExit=0; result.block=0; - result.isRaise=(result.code==T_BTN_RAISE); - result.isPressable=1; - result.hasSkeleton=0; - result.hasSpikes=0; - result.hasTorch=0; - result.hasFloor=0;/*(result.code==T_BTN_DROP);*/ - result.hasBrokenTile=0; - result.isWall=0; - result.hasSword=0; break; - case T_FLOOR: - case T_TORCH: - case T_SWORD: - case T_CHOPPER: - case T_POTION: - case T_SPIKES: - case T_BP_BOTTOM: - case T_TORCH_DEBRIS: - case T_EXIT_RIGHT: - case T_SKELETON: - case T_LOOSE: - case T_PILLAR: - case T_DEBRIS: - result.hasGateFrame=0; - result.bricks=(result.code==T_FLOOR)?result.back:0; - result.hasPillar=(result.code==T_PILLAR); - result.hasBigPillar=(result.code==T_BP_BOTTOM); - result.isGate=0; + case TILE_FLOOR: + case TILE_TORCH: + case TILE_SWORD: + case TILE_CHOPPER: + case TILE_POTION: + case TILE_SPIKES: + case TILE_BP_BOTTOM: + case TILE_TORCH_DEBRIS: + case TILE_EXIT_RIGHT: + case TILE_SKELETON: + case TILE_LOOSE: + case TILE_PILLAR: + case TILE_DEBRIS: + result.bricks=(result.code==TILE_FLOOR)?result.back:0; + result.hasBigPillar=(result.code==TILE_BP_BOTTOM); result.walkable=1; - result.hasChopper=(result.code==T_CHOPPER); - result.isExit=(result.code==T_EXIT_LEFT)?1:((result.code==T_EXIT_RIGHT)?2:0); + result.isExit=(result.code==TILE_EXIT_LEFT)?1:((result.code==TILE_EXIT_RIGHT)?2:0); result.block=0; - result.isRaise=0; - result.hasPotion=(result.code==T_POTION); - result.isPressable=0; - result.hasSkeleton=(result.code==T_SKELETON); - result.hasSpikes=(result.code==T_SPIKES); - result.hasTorch=(result.code==T_TORCH)|(result.code==T_TORCH_DEBRIS); - result.hasFloor=((result.code==T_FLOOR)|(result.code==T_TORCH)|(result.code==T_LOOSE)|(result.code==T_POTION)|(result.code==T_SWORD)|(result.code==T_CHOPPER)); - result.hasBrokenTile=(result.code==T_DEBRIS)|(result.code==T_TORCH_DEBRIS); - result.isWall=0; - result.hasSword=(result.code==T_SWORD); break; - case T_WALL: - result.hasGateFrame=0; + case TILE_WALL: result.bricks=0; - result.hasPillar=0; - result.isRaise=0; result.hasBigPillar=0; result.walkable=0; - result.hasPotion=0; - result.hasChopper=0; result.isExit=0; - result.isGate=0; - result.isPressable=0; - result.hasSkeleton=0; - result.hasSpikes=0; result.block=1; - result.hasTorch=0; - result.hasFloor=0; - result.hasBrokenTile=0; - result.isWall=1; - result.hasSword=0; break; - case T_EMPTY: - case T_TAPESTRY_TOP: - case T_BP_TOP: + case TILE_EMPTY: + case TILE_TAPESTRY_TOP: + case TILE_BP_TOP: default: - result.hasGateFrame=(result.code==T_TAPESTRY_TOP); - result.hasBigPillar=(result.code==T_BP_TOP)*2; + result.hasBigPillar=(result.code==TILE_BP_TOP)*2; result.bricks=result.back; - result.hasPillar=0; result.walkable=0; result.isExit=0; - result.isGate=0; - result.hasPotion=0; - result.hasChopper=0; - result.isRaise=0; - result.isPressable=0; - result.hasSkeleton=0; - result.hasSpikes=0; result.block=0; - result.hasTorch=0; - result.hasFloor=0; - result.hasBrokenTile=0; - result.isWall=0; - result.hasSword=0; break; } + /*isIn(result,TILES_PILLAR)=isIn(result,TILES_PILLAR); + isIn(result,TILES_CHOPPER)=isIn(result,TILES_CHOPPER); + isIn(result,TILES_POTION)=isIn(result,TILES_POTION); + isIn(result,TILES_SPIKES)=isIn(result,TILES_SPIKES); + isIn(result,TILES_BROKENTILE)=isIn(result,TILES_BROKENTILE); + isIn(result,TILES_FLOOR)=isIn(result,TILES_FLOOR); + isIn(result,TILES_GATEFRAME)=isIn(result,TILES_GATEFRAME); + isIn(result,TILES_SKELETON)=isIn(result,TILES_SKELETON); + isIn(result,TILES_SWORD)=isIn(result,TILES_SWORD); + isIn(result,TILES_TORCH)=isIn(result,TILES_TORCH); + isIn(result,TILES_DOOR)=isIn(result,TILES_DOOR); + isIn(result,TILES_PRESSABLE)=isIn(result,TILES_PRESSABLE); + isIn(result,TILES_RAISE)=isIn(result,TILES_RAISE); + isIn(result,TILES_WALL)=isIn(result,TILES_WALL);*/ return result; } @@ -302,8 +247,8 @@ void drawBackPanel(tRoom* room,int x, int y) { tTile left=roomGetTile(room,x-1,y); /* Wall/left */ - if (!tile.isWall) { - if (left.isWall) { + if (!isIn(tile,TILES_WALL)) { + if (isIn(left,TILES_WALL)) { outputDrawBitmap( roomGfx.environment->pFrames[63], (x-1)*TILE_W, @@ -312,7 +257,7 @@ void drawBackPanel(tRoom* room,int x, int y) { } } /* Gate/left */ - if (left.isGate) { + if (isIn(left,TILES_DOOR)) { outputDrawBitmap( roomGfx.environment->pFrames[15], (x-1)*TILE_W, @@ -321,7 +266,7 @@ void drawBackPanel(tRoom* room,int x, int y) { drawGate((x-1)*TILE_W,(y-1)*TILE_H+3,((tGate*)left.moreInfo)->frame); } /* normal/left */ - if (left.hasFloor) { + if (isIn(left,TILES_FLOOR)) { outputDrawBitmap( roomGfx.environment->pFrames[10], (x-1)*TILE_W, @@ -337,7 +282,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* pillar/left */ - if (left.hasPillar) { + if (isIn(left,TILES_PILLAR)) { outputDrawBitmap( roomGfx.environment->pFrames[44], (x-1)*TILE_W, @@ -361,8 +306,8 @@ void drawBackPanel(tRoom* room,int x, int y) { } } /* pressable/left */ - if (left.isPressable) { - if (left.isRaise) { + if (isIn(left,TILES_PRESSABLE)) { + if (isIn(left,TILES_RAISE)) { outputDrawBitmap( roomGfx.environment->pFrames[10], (x-1)*TILE_W, @@ -377,7 +322,7 @@ void drawBackPanel(tRoom* room,int x, int y) { } } /* debris/left */ - if (left.hasBrokenTile) { + if (isIn(left,TILES_BROKENTILE)) { outputDrawBitmap( roomGfx.environment->pFrames[49], (x-1)*TILE_W, @@ -385,7 +330,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* spikes/left */ - if (left.hasSpikes) { + if (isIn(left,TILES_SPIKES)) { outputDrawBitmap( roomGfx.environment->pFrames[107], (x-1)*TILE_W, @@ -394,7 +339,7 @@ void drawBackPanel(tRoom* room,int x, int y) { drawSpike((x-2)*TILE_W,y*TILE_H,room->level->time%6,layRight); } /* skeleton/left */ - if (left.hasSkeleton) { + if (isIn(left,TILES_SKELETON)) { outputDrawBitmap( roomGfx.environment->pFrames[81], (x-1)*TILE_W, @@ -402,7 +347,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* torch/this */ - if (tile.hasTorch) { /* animation */ + if (isIn(tile,TILES_TORCH)) { /* animation */ outputDrawBitmap( roomGfx.torch->pFrames[ ((room->level->time)+2*x+y)%(roomGfx.torch->frames) @@ -417,11 +362,11 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* chopper/this */ - if (tile.hasChopper) { + if (isIn(tile,TILES_CHOPPER)) { drawChopper((x-1)*TILE_W,y*TILE_H,room->level->time%8,layCBack); } /* empty_bricks/this */ - if ((0<tile.bricks)&&(tile.bricks<4)&&(tile.code==T_EMPTY)) { + if ((0<tile.bricks)&&(tile.bricks<4)&&(tile.code==TILE_EMPTY)) { outputDrawBitmap( roomGfx.environment->pFrames[51+tile.bricks], x*TILE_W, @@ -429,7 +374,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* floor_bricks/this */ - if ((0<tile.bricks)&&(tile.bricks<3)&&(tile.code==T_FLOOR)) { + if ((0<tile.bricks)&&(tile.bricks<3)&&(tile.code==TILE_FLOOR)) { outputDrawBitmap( roomGfx.environment->pFrames[11+tile.bricks], x*TILE_W, @@ -437,7 +382,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* gate/this */ - if (tile.isGate) { + if (isIn(tile,TILES_DOOR)) { outputDrawBitmap( roomGfx.environment->pFrames[14], (x-1)*TILE_W, @@ -445,7 +390,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* gate_frame/this */ - if (tile.hasGateFrame) { + if (isIn(tile,TILES_GATEFRAME)) { outputDrawBitmap( roomGfx.environment->pFrames[17], (x-1)*TILE_W+24, @@ -453,7 +398,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* normal/this */ - if (tile.hasFloor) { + if (isIn(tile,TILES_FLOOR)) { outputDrawBitmap( roomGfx.environment->pFrames[9], (x-1)*TILE_W, @@ -478,7 +423,7 @@ void drawBackPanel(tRoom* room,int x, int y) { } } /* pillar/this */ - if (tile.hasPillar) { + if (isIn(tile,TILES_PILLAR)) { outputDrawBitmap( roomGfx.environment->pFrames[43], (x-1)*TILE_W, @@ -502,10 +447,10 @@ void drawBackPanel(tRoom* room,int x, int y) { } } /* pressable/this */ - if (tile.isPressable) { - if (tile.isRaise) { + if (isIn(tile,TILES_PRESSABLE)) { + if (isIn(tile,TILES_RAISE)) { outputDrawBitmap( - roomGfx.environment->pFrames[(((tPressable*)tile.moreInfo)->action==eNormal)?(58-((left.walkable)&&(!left.isRaise))):58], + roomGfx.environment->pFrames[(((tPressable*)tile.moreInfo)->action==eNormal)?(58-((left.walkable)&&(!isIn(left,TILES_RAISE)))):58], (x-1)*TILE_W, y*TILE_H+((((tPressable*)tile.moreInfo)->action==eNormal)?0:1) ); @@ -518,7 +463,7 @@ void drawBackPanel(tRoom* room,int x, int y) { } } /* debris/this */ - if (tile.hasBrokenTile) { + if (isIn(tile,TILES_BROKENTILE)) { outputDrawBitmap( roomGfx.environment->pFrames[48], (x-1)*TILE_W, @@ -526,7 +471,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* chopper/this / - if (tile.hasChopper) { + if (isIn(tile,TILES_CHOPPER)) { outputDrawBitmap( roomGfx.environment->pFrames[9], (x-1)*TILE_W, @@ -534,7 +479,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); }*/ /* spikes/this */ - if (tile.hasSpikes) { + if (isIn(tile,TILES_SPIKES)) { outputDrawBitmap( roomGfx.environment->pFrames[101], (x-1)*TILE_W, @@ -543,7 +488,7 @@ void drawBackPanel(tRoom* room,int x, int y) { drawSpike((x-1)*TILE_W,y*TILE_H,room->level->time%6,layFore); } /* skeleton/this */ - if (tile.hasSkeleton) { + if (isIn(tile,TILES_SKELETON)) { outputDrawBitmap( roomGfx.environment->pFrames[80], (x-1)*TILE_W, @@ -551,7 +496,7 @@ void drawBackPanel(tRoom* room,int x, int y) { ); } /* potion/left */ - if (left.hasPotion) { /* animation */ + if (isIn(left,TILES_POTION)) { /* animation */ outputDrawBitmap( roomGfx.potionAnim->pFrames[ ((room->level->time)+2*x+y)%(roomGfx.potionAnim->frames) @@ -573,7 +518,7 @@ void drawBackBottomTile(tRoom* room,int x, int y) { /* normal */ if (tile.walkable) { - if (tile.isPressable) { + if (isIn(tile,TILES_PRESSABLE)) { outputDrawBitmap( /* TODO: drop has resource 59 for unpressed/reise 47? check game */ roomGfx.environment->pFrames[59], (x-1)*TILE_W, @@ -588,18 +533,18 @@ void drawBackBottomTile(tRoom* room,int x, int y) { } } else { /* wall */ - if (tile.isWall) { + if (isIn(tile,TILES_WALL)) { tTile left; tTile right; void* image; left=roomGetTile(room,x-1,y); right=roomGetTile(room,x+1,y); /* there are 4 cases */ - if (left.isWall&&right.isWall) { + if (isIn(left,TILES_WALL)&&isIn(right,TILES_WALL)) { image=roomGfx.environment->pFrames[65]; - } else if ((!left.isWall)&&(right.isWall)) { + } else if ((!isIn(left,TILES_WALL))&&(isIn(right,TILES_WALL))) { image=roomGfx.environment->pFrames[71]; - } else if ((left.isWall)&&(!right.isWall)) { + } else if ((isIn(left,TILES_WALL))&&(!isIn(right,TILES_WALL))) { image=roomGfx.environment->pFrames[67]; } else { image=roomGfx.environment->pFrames[69]; @@ -613,7 +558,7 @@ void drawBackBottomTile(tRoom* room,int x, int y) { /* empty */ tTile dleft=roomGetTile(room,x-1,y+1); /* gate_frame/this */ - if (tile.hasGateFrame) { + if (isIn(tile,TILES_GATEFRAME)) { outputDrawBitmap( roomGfx.environment->pFrames[42], (x-1)*TILE_W, @@ -621,7 +566,7 @@ void drawBackBottomTile(tRoom* room,int x, int y) { ); } /* gate/left */ - if (dleft.isGate) { + if (isIn(dleft,TILES_DOOR)) { outputDrawBitmap( roomGfx.environment->pFrames[16], (x-1)*TILE_W, @@ -638,7 +583,7 @@ void drawBackBottomTile(tRoom* room,int x, int y) { ); } /* pillar/left */ - if (dleft.hasPillar) { + if (isIn(dleft,TILES_PILLAR)) { outputDrawBitmap( roomGfx.environment->pFrames[45], (x-1)*TILE_W, @@ -646,7 +591,7 @@ void drawBackBottomTile(tRoom* room,int x, int y) { ); } /* pillar/left */ - if (dleft.isWall) { + if (isIn(dleft,TILES_WALL)) { outputDrawBitmap( roomGfx.environment->pFrames[64], (x-1)*TILE_W, @@ -670,7 +615,7 @@ void drawForePanel(tRoom* room,int x, int y) { tTile tile=roomGetTile(room,x,y); /* pillar */ - if (tile.hasPillar) { + if (isIn(tile,TILES_PILLAR)) { outputDrawBitmap( roomGfx.environment->pFrames[46], x*TILE_W-24, @@ -686,7 +631,7 @@ void drawForePanel(tRoom* room,int x, int y) { ); } /* wall */ - if (tile.isWall) { + if (isIn(tile,TILES_WALL)) { /*static unsigned short seedArray[]=WALL_PROPERTIES;*/ register short seed; int cases; @@ -697,14 +642,14 @@ void drawForePanel(tRoom* room,int x, int y) { right=roomGetTile(room,x+1,y); seed=room->id+(x-1)+(y-1)*10-1; /* there are 4 cases */ - if (left.isWall&&right.isWall) { + if (isIn(left,TILES_WALL)&&isIn(right,TILES_WALL)) { /* First step: calculate the seed position and get the element */ cases=WALL_LOC_WWW; outputDrawBitmap(roomGfx.environment->pFrames[66],(x-1)*TILE_W,y*TILE_H); - } else if ((!left.isWall)&&(right.isWall)) { + } else if ((!isIn(left,TILES_WALL))&&(isIn(right,TILES_WALL))) { cases=WALL_LOC_SWW; outputDrawBitmap(roomGfx.environment->pFrames[72],(x-1)*TILE_W,y*TILE_H); - } else if ((left.isWall)&&(!right.isWall)) { + } else if ((isIn(left,TILES_WALL))&&(!isIn(right,TILES_WALL))) { cases=WALL_LOC_WWS; outputDrawBitmap(roomGfx.environment->pFrames[68],(x-1)*TILE_W,y*TILE_H); } else { @@ -779,7 +724,7 @@ void drawForePanel(tRoom* room,int x, int y) { } /* debris/this foreground layer */ - if (tile.hasBrokenTile) { + if (isIn(tile,TILES_BROKENTILE)) { outputDrawBitmap( roomGfx.environment->pFrames[51], (x-1)*TILE_W, diff --git a/FP/src/ker/titles.c b/FP/src/ker/titles.c index f73e01c..ceb4d9a 100644 --- a/FP/src/ker/titles.c +++ b/FP/src/ker/titles.c @@ -66,25 +66,27 @@ tMenuOption getAction(tKey key) { } tMenuOption playAnimation(int id) { + /* Declare variables */ - int qf, qt, qo, i; - animImage* f; animObject* t; animSound* o; - titleImage* fa; titleObject* ta; /*animSound* oa;*/ - int activef=0; int activet=0; /*int activeo=0;*/ - int totalf, totalt, totalo; + int imgCount, objCount, sndCount, i; + animImage* img; animObject* obj; animSound* snd; + titleImage* imgArray; titleObject* objArray; /*animSound* sndArray;*/ + int imgsActive=0; int objsActive=0; /*int sndsActive=0;*/ + int imgTotal, objTotal, sndTotal; + tKey key=inputCreateKey(); tKey nullKey=inputCreateKey(); /* Initialize animation and allocate memory */ - animStart(id,&totalf,&totalt,&totalo); - fa=(titleImage*)malloc(totalf*sizeof(titleImage)); - ta=(titleObject*)malloc(totalt*sizeof(titleObject)); - /*oa=(animSound*)malloc(totalo*sizeof(animSound));*/ + animStart(id,&imgTotal,&objTotal,&sndTotal); + imgArray=(titleImage*)malloc(imgTotal*sizeof(titleImage)); + objArray=(titleObject*)malloc(objTotal*sizeof(titleObject)); + /*sndArray=(animSound*)malloc(sndTotal*sizeof(animSound));*/ /* main animation kernel loop */ - while (animGetFrame(&qf,&qt,&qo,&f,&t,&o)) { + while (animGetFrame(&imgCount,&objCount,&sndCount,&img,&obj,&snd)) { int reprocessInput=1; - /*printf("f%d t%d o%d\n",qf,qt,qo);*/ + while(reprocessInput) { if (!inputGetEvent(&key)) { /* key pressed */ @@ -92,94 +94,91 @@ tMenuOption playAnimation(int id) { /* if there is an action and the action wasn't control key */ if (key.actionPerformed!=none && !(inputGetCtrl(key.status)&&key.actionPerformed==other)) return getAction(key); - reprocessInput=1; } else { reprocessInput=0; /* create new images/objects/sounds */ - for (i=0;i<qf;i++) { /*images*/ - fa[activef].img=resLoad(f[i].res); - if (!fa[activef].img) { + for (i=0;i<imgCount;i++) { /*images*/ + imgArray[imgsActive].img=resLoad(img[i].res); + if (!imgArray[imgsActive].img) { fprintf(stderr,"resource coudn't be loaded."); return menuQuit; } - 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++; + imgArray[imgsActive].y=img[i].y; + imgArray[imgsActive].x=img[i].x; + imgArray[imgsActive].layer=img[i].layer; + imgArray[imgsActive].duration=img[i].duration; + imgsActive++; } - for (i=0;i<qt;i++) { /*objects*/ - ta[activet].obj=objectCreate(t[i].location,t[i].floor,DIR_LEFT,t[i].state,t[i].res,t[i].cacheMirror); - ta[activet].active=1; - ta[activet].duration=t[i].duration; - printf("saving duration[%d]=%d\n",i,t[i].duration); - activet++; + for (i=0;i<objCount;i++) { /*objects*/ + objArray[objsActive].obj=objectCreate(obj[i].location,obj[i].floor,DIR_LEFT,obj[i].state,obj[i].res,obj[i].cacheMirror); + objArray[objsActive].active=1; + objArray[objsActive].duration=obj[i].duration; + objsActive++; } /* TODO: code sounds - * for (i=0;i<qo;i++) { - fa[activeo]=o[i]; - activeo++; + * for (i=0;i<sndCount;i++) { + sndArray[sndsActive]=snd[i]; + sndsActive++; }*/ 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); + for (i=0;i<imgsActive;i++) { + if (imgArray[i].layer==ANIMS_LAYERTYPE_BOTTOM) + outputDrawBitmap(imgArray[i].img->pFrames[0], imgArray[i].x, imgArray[i].y); } /* move objects */ - for (i=0;i<activet;i++) { + for (i=0;i<objsActive;i++) { /*TODO: detect exits */ - if (ta[i].active) { + if (objArray[i].active) { int exitCode; - exitCode=objectMove(&(ta[i].obj),nullKey,NULL); - if (ta[i].duration) ta[i].duration--; - printf("decrementing duration[%d]=%d\n",i,ta[i].duration); + exitCode=objectMove(&(objArray[i].obj),nullKey,NULL); + if (objArray[i].duration) objArray[i].duration--; /* detect exited states and destroy them */ /* if the time is over or exit code detected */ - if ((ta[i].duration==1)||(exitCode<0)) { + if ((objArray[i].duration==1)||(exitCode<0)) { printf("exit Code detected: i=%d exit=%d \n",i,exitCode); - objectFree(ta[i].obj); - ta[i].active=0; /* remember it is destroyed */ + objectFree(objArray[i].obj); + objArray[i].active=0; /* remember it is destroyed */ } else { - objectDraw(ta[i].obj); + objectDraw(objArray[i].obj); } } } /* 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); + for (i=0;i<imgsActive;i++) { + if (imgArray[i].layer==ANIMS_LAYERTYPE_TOP) { + outputDrawBitmap(imgArray[i].img->pFrames[0], imgArray[i].x, imgArray[i].y); } } outputUpdateScreen(); /* caducied backgrounds destruction */ - i=activef; + i=imgsActive; while(i) { 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]; + if (imgArray[i].duration) { /* if not 0 (infinite) */ + imgArray[i].duration--; + if (!imgArray[i].duration) { /* time is over for this images */ + imgsActive--; + resFree(imgArray[i].img); + imgArray[i]=imgArray[imgsActive]; } } } } } } - for (i=0;i<activet;i++) if (ta[i].active) objectFree(ta[i].obj); - for (i=0;i<activef;i++) resFree(fa[i].img); - free(fa); - free(ta); - /*free(oa);*/ + for (i=0;i<objsActive;i++) if (objArray[i].active) objectFree(objArray[i].obj); + for (i=0;i<imgsActive;i++) resFree(imgArray[i].img); + free(imgArray); + free(objArray); + /*free(sndArray);*/ return menuQuit; } diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index 3e3114b..6e3f9f4 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -36,6 +36,7 @@ maps.c: Freeprince : Map handling library #include "room.h" #include "kid.h" #include "types.h" +#include "tiles.h" #define slevel(field) (map->field) @@ -57,10 +58,10 @@ void* mapLoadLevel(tMemory level) { /* generate and load gate structures */ for (i=0;i<24;i++) { /* count gates and create gate tree middle nodes */ for (j=0;j<30;j++) { - if (((map->fore[i*30+j]&0x1f)==T_GATE)||((map->fore[i*30+j]&0x1f)==T_EXIT_LEFT)) { + if (((map->fore[i*30+j]&0x1f)==TILE_GATE)||((map->fore[i*30+j]&0x1f)==TILE_EXIT_LEFT)) { gateInRoom++; gates++; - } else if (((map->fore[i*30+j]&0x1f)==T_BTN_RAISE)||((map->fore[i*30+j]&0x1f)==T_BTN_DROP)) { + } else if (((map->fore[i*30+j]&0x1f)==TILE_BTN_RAISE)||((map->fore[i*30+j]&0x1f)==TILE_BTN_DROP)) { pressableInRoom++; pressables++; } @@ -87,22 +88,22 @@ void* mapLoadLevel(tMemory level) { pressables=0; for (i=0;i<24;i++) { for (j=0;j<30;j++) { - if (((map->fore[i*30+j]&0x1f)==T_GATE)||((map->fore[i*30+j]&0x1f)==T_EXIT_LEFT)) { + if (((map->fore[i*30+j]&0x1f)==TILE_GATE)||((map->fore[i*30+j]&0x1f)==TILE_EXIT_LEFT)) { tGate newGate; newGate.frame=map->back[i*30+j]; newGate.action=map->back[i*30+j]?eClose:eOpen; - newGate.type=((map->fore[i*30+j]&0x1f)==T_GATE)?eNormalGate:eExitGate; + newGate.type=((map->fore[i*30+j]&0x1f)==TILE_GATE)?eNormalGate:eExitGate; map->back[i*30+j]=gateInRoom; map->screenGates[i][gateInRoom]=map->gates+gates; auxGates[i*30+j]=map->gates+gates; fprintf(stderr,"mapLoadLevel: Loading gate: indexed=%d gate pointer=%p\n",i,(void*)auxGates[i*30+j]); map->gates[gates++]=newGate; gateInRoom++; - } else if (((map->fore[i*30+j]&0x1f)==T_BTN_RAISE)||((map->fore[i*30+j]&0x1f)==T_BTN_DROP)) { + } else if (((map->fore[i*30+j]&0x1f)==TILE_BTN_RAISE)||((map->fore[i*30+j]&0x1f)==TILE_BTN_DROP)) { tPressable newPressable; newPressable.event=map->events+map->back[i*30+j]; newPressable.action=eNormal; - newPressable.type=((map->fore[i*30+j]&0x1f)==T_BTN_RAISE)?eRaise:eDrop; + newPressable.type=((map->fore[i*30+j]&0x1f)==TILE_BTN_RAISE)?eRaise:eDrop; map->back[i*30+j]=pressableInRoom; map->screenPressables[i][pressableInRoom]=map->pressables+pressables; fprintf(stderr,"mapLoadLevel: Creating button: indexed=%d,%d btn pointer=%p\n",i,pressableInRoom,(void*)(map->pressables+pressables)); @@ -347,19 +348,19 @@ void mapMove(tMap* map) { int mapPressedTile(tMap* map, tTile tile, int s, int x, int y) { int refresh=0; - if (tile.isPressable) { + if (isIn(tile,TILES_PRESSABLE)) { tEvent* event; ((tPressable*)tile.moreInfo)->action=eJustPressed; /* drop or raise button */ event=((tPressable*)tile.moreInfo)->event; fprintf(stderr,"mapPressedTile: throw event from button %d event:%p\n",tile.back,(void*)event); do { - event->gate->action=tile.isRaise?eOpening:eClosingFast; + event->gate->action=isIn(tile,TILES_RAISE)?eOpening:eClosingFast; } while ((event++)->triggerNext); } printf("s=%d x=%d y=%d\n",s,x,y); - if (tile.code==T_LOOSE) { - map->fore[(s-1)*30+(x-1)+(y-1)*10]=T_EMPTY; + if (tile.code==TILE_LOOSE) { + map->fore[(s-1)*30+(x-1)+(y-1)*10]=TILE_EMPTY; refresh=1; /* room changed, refresh it */ } return refresh; diff --git a/FP/src/res/tiles.c b/FP/src/res/tiles.c index 4960a99..ed4a8b0 100644 --- a/FP/src/res/tiles.c +++ b/FP/src/res/tiles.c @@ -33,7 +33,7 @@ tiles.c: FreePrince : Tile functions #include "tiles.h" int isInGroup(unsigned char tile,unsigned char backtile,short group) { - static unsigned char tileList[]=TILES_GROUP_LIST; + static unsigned char tileList[]=TILE_GROUP_LIST; unsigned char* i=tileList+group; int docontinue; tile=tile&0x1F; /* get the last 5 bits and clear the beginning */ @@ -50,3 +50,7 @@ int isInGroup(unsigned char tile,unsigned char backtile,short group) { return *i; /* returns non-zero if true and zero if false */ } +int isIn(tTile tile,short group) { + return isInGroup(tile.code,tile.back,group); +} + diff --git a/stuff/FP-Attic/states_conf_properties.awk b/stuff/FP-Attic/states_conf_properties.awk index 1ee6ca6..9ffedca 100644 --- a/stuff/FP-Attic/states_conf_properties.awk +++ b/stuff/FP-Attic/states_conf_properties.awk @@ -29,6 +29,6 @@ # /^([ ]*[^# ].*)$/ { - printf("#define STATES_COND_%s %d\n",$1,$2) + printf("#define STATES_COND_%s %d\n",toupper($1),$2) }