author | ecalot
<ecalot> 2005-01-15 21:17:33 UTC |
committer | ecalot
<ecalot> 2005-01-15 21:17:33 UTC |
parent | 73e66679d04ac7a0865a705f941cc0a873906d57 |
FP/src/Makefile | +5 | -4 |
FP/src/include/kid.h | +1 | -12 |
FP/src/include/object.h | +3 | -5 |
FP/src/include/types.h | +2 | -1 |
FP/src/ker/kernel.c | +1 | -1 |
FP/src/ker/object.c | +1 | -0 |
FP/src/ker/room.c | +21 | -6 |
FP/src/ker/states.c | +4 | -3 |
FP/src/ker/titles.c | +1 | -1 |
FP/src/res/maps.c | +35 | -2 |
diff --git a/FP/src/Makefile b/FP/src/Makefile index 5308b4e..2453ee7 100644 --- a/FP/src/Makefile +++ b/FP/src/Makefile @@ -150,7 +150,7 @@ dat.o: res/dat.c include/disk.h include/dat.h $(CC) -c res/dat.c $(OPTIONS) kernel.o: ker/kernel.c include/kernel.h include/resources.h\ - include/res_conf.h include/output.h include/kid.h\ + include/res_conf.h include/output.h include/object.h\ $(GENERATEDSTAHEADERS) $(INFO) Compiling main kernel... $(CC) -c ker/kernel.c $(OPTIONS) @@ -166,16 +166,17 @@ kid.o: ker/kid.c include/kid.h include/states.h $(GENERATEDSTAHEADERS) \ $(INFO) Compiling kernel object support... $(CC) -c ker/kid.c $(OPTIONS) -object.o: ker/object.c include/kid.h include/resources.h include/res_conf.h\ +object.o: ker/object.c include/object.h include/resources.h include/res_conf.h\ include/states.h $(GENERATEDRESHEADERS)\ $(GENERATEDSTAHEADERS) $(GENERATEDTILHEADERS) include/res_conf.h\ - include/types.h include/tiles.h include/tiles_conf.h include/output.h + include/types.h include/tiles.h include/tiles_conf.h include/output.h\ + include/kid.h $(INFO) Compiling kernel kid object support... $(CC) -c ker/object.c $(OPTIONS) titles.o: ker/titles.c include/resources.h include/res_conf.h\ include/anims_conf.h $(GENERATEDSTAHEADERS) $(GENERATEDRESHEADERS)\ - include/kid.h + include/object.h $(INFO) Compiling kernel titles module... $(CC) -c ker/titles.c $(OPTIONS) diff --git a/FP/src/include/kid.h b/FP/src/include/kid.h index e0a065e..f653b72 100644 --- a/FP/src/include/kid.h +++ b/FP/src/include/kid.h @@ -19,7 +19,7 @@ */ /* -kid.h: Free Prince : Kid and other object +kid.h: Free Prince : Kid object \xaf\xaf\xaf\xaf\xaf Copyright 2004 Princed Development Team Created: 19 Jul 2004 @@ -34,21 +34,10 @@ kid.h: Free Prince : Kid and other object #define _KID_H_ #include "resources.h" -#include "input.h" #include "room.h" -#define DIR_LEFT 1 -#define DIR_RIGHT 0 - -#define object_getLocation(object,image) ((object).location/*-(outputGetWidth(image)>>1)*/) - #include "types.h" -tObject objectCreate(int location, int floor, int direction, int stateId, unsigned long resId, int cacheMirror, tObjectType type); -void objectDraw(tObject obj); -int objectMove(tObject* obj,tKey key,tRoom* room); -void objectFree(tObject obj); - int kidMove(tObject* kid,short flags,tRoom* room); #endif diff --git a/FP/src/include/object.h b/FP/src/include/object.h index e0a065e..a368df5 100644 --- a/FP/src/include/object.h +++ b/FP/src/include/object.h @@ -19,7 +19,7 @@ */ /* -kid.h: Free Prince : Kid and other object +kid.h: Free Prince : Generic objects \xaf\xaf\xaf\xaf\xaf Copyright 2004 Princed Development Team Created: 19 Jul 2004 @@ -30,8 +30,8 @@ kid.h: Free Prince : Kid and other object DO NOT remove this copyright notice */ -#ifndef _KID_H_ -#define _KID_H_ +#ifndef _OBJECT_H_ +#define _OBJECT_H_ #include "resources.h" #include "input.h" @@ -49,7 +49,5 @@ void objectDraw(tObject obj); int objectMove(tObject* obj,tKey key,tRoom* room); void objectFree(tObject obj); -int kidMove(tObject* kid,short flags,tRoom* room); - #endif diff --git a/FP/src/include/types.h b/FP/src/include/types.h index f4771d9..5b52dbf 100644 --- a/FP/src/include/types.h +++ b/FP/src/include/types.h @@ -76,7 +76,8 @@ typedef struct { typedef struct { int frame; - enum {eChoMoving,eChoWaiting,eChoClosed,eSpiDown,eSpiStuck} action; + enum {eChoMoving,eChoWaiting,eChoClosed,eSpiUp,eSpiWaitUp,eSpiDown,eSpiStuck} action; + int time; } tDanger; typedef struct { diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c index c8e5adc..17d84cb 100644 --- a/FP/src/ker/kernel.c +++ b/FP/src/ker/kernel.c @@ -39,7 +39,7 @@ kernel.c: FreePrince : Main Kernel #include "input.h" #include "titles.h" #include "states.h" /* stateKidInLevel */ -#include "kid.h" +#include "object.h" #include "room.h" #include "maps.h" diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c index f491490..00313cb 100644 --- a/FP/src/ker/object.c +++ b/FP/src/ker/object.c @@ -36,6 +36,7 @@ object.h: Free Prince : Objects #include "maps.h" /* mapGetRoom getTile */ #include <stdio.h> /* NULL */ #include "states.h" +#include "object.h" void loadGfx(int storeMirrored, tData** gfxCache, unsigned long resId) { gfxCache[DIR_LEFT]=resLoad(resId); diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c index fb584a1..c316dc5 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 "object.h" /* DIR_LEFT DIR_RIGHT */ #include "tiles.h" #include "maps.h" #include "walls.h" @@ -101,6 +102,14 @@ tTile roomGetTile(tRoom* room,int x, int y) { /* 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]; + } else if (isIn(result,TILES_CHOPPER_SPIKE)) { + 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]; + if (roomId<24) + result.moreInfo=room->level->screenDangers[roomId-1][result.back]; } return result; } @@ -111,9 +120,11 @@ tTile roomGetTile(tRoom* room,int x, int y) { #define e(a,x,y) outputDrawBitmap(roomGfx.environment->pFrames[a],(x),(y)) -#define buttonIsNormal(a) (((tPressable*)a.moreInfo)->action==eNormal) -#define gateGetFrame(a) (((tGate*)a.moreInfo)->frame) -#define wallGetInfo(a) wallGet(env,cases,(a),seed) +#define buttonIsNormal(a) (((tPressable*)a.moreInfo)->action==eNormal) +#define chopperGetFrame(a) (((tDanger*)a.moreInfo)->frame) +#define gateGetFrame(a) (((tGate*)a.moreInfo)->frame) +#define spikeGetFrame(a) (((tDanger*)a.moreInfo)->frame) +#define wallGetInfo(a) (wallGet(env,cases,(a),seed)) /* door drawing */ #define drawGateTop(x,y,frame) outputDrawBitmap(roomGfx.environment->pFrames[35-((frame)&7)],x,y) @@ -214,7 +225,7 @@ void drawBackPanel(tRoom* room,int x, int y) { /* spikes/left */ if (isIn(left,TILES_SPIKES)) { e(107,(x-1)*TILE_W+0,y*TILE_H+2); - drawSpike((x-2)*TILE_W+0,y*TILE_H,room->level->time%6,layRight); + drawSpike((x-2)*TILE_W+0,y*TILE_H,spikeGetFrame(left),layRight); } /* skeleton/left */ if (isIn(left,TILES_SKELETON)) @@ -281,7 +292,7 @@ void drawBackPanel(tRoom* room,int x, int y) { /* spikes/this */ if (isIn(tile,TILES_SPIKES)) { e(101,(x-1)*TILE_W+0,y*TILE_H+0); - drawSpike((x-1)*TILE_W+0,y*TILE_H,room->level->time%6,layFore); + drawSpike((x-1)*TILE_W+0,y*TILE_H,spikeGetFrame(tile),layFore); } /* skeleton/this */ if (isIn(tile,TILES_SKELETON)) @@ -507,18 +518,22 @@ int roomPress(tRoom* room, tObject* obj) { if ((obj->location%TILE_W)<WHERE_IN){ where=border;i=-1;} - if (where!=middle) { + if (where!=middle) { /* TODO: the first case is different. + * try to make it as similar as possible */ if (isIn(aux=roomGetTile(room,x+i,y),TILES_CHOPPER_SPIKE)) { /* 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_CHOPPER_SPIKE)) { /* 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_CHOPPER_SPIKE)) { /* spikes left in the 2 level lower floor, there are * spaces so you can fall down */ tDanger* danger=aux.moreInfo; + /*danger->action=eSpiUp;*/ } } return refresh; diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c index 4420827..ad148d1 100644 --- a/FP/src/ker/states.c +++ b/FP/src/ker/states.c @@ -34,7 +34,7 @@ states.c: FreePrince : State object #include <stdlib.h> #include "tiles.h" /* isInGroup & groups */ #include <stdio.h> /* For debug purposes */ -#include "kid.h" /* DIR_LEFT DIR_RIGHT */ +#include "object.h" /* DIR_LEFT DIR_RIGHT */ void debugShowFlag(short optionflag) { if (optionflag&STATES_FLAG_F) printf("Falling "); @@ -238,8 +238,9 @@ short stateUpdate(tKey* key, tObject* kid,tRoom* room) { break; case STATES_MOVETYPES_ABSOLUTEONSTOP: { /* AbsoluteOnStop (x) - * Deletes frames (in the middle) to make sure that, at the end of the animation, - * the kid had moved only x step units from the first forward tile change + * Deletes frames (in the middle) to make sure that, at the end of + * the animation, the kid had moved only x step units from the first + * forward tile change * if there is a lack of movements by frame it stops before reaching it. */ /* 1) calculate the number of frames the guy will move */ diff --git a/FP/src/ker/titles.c b/FP/src/ker/titles.c index e8b3596..f5e26ae 100644 --- a/FP/src/ker/titles.c +++ b/FP/src/ker/titles.c @@ -38,7 +38,7 @@ titles.c: FreePrince : Titles, animation and presentation #include <stdlib.h> /* malloc/free */ #include "anims.h" -#include "kid.h" +#include "object.h" typedef struct { tData* img; diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index a1dd913..1704c0d 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -97,7 +97,7 @@ void* mapLoadLevel(tMemory level) { map->totalGates=gates; map->pressables=malloc(pressables*sizeof(tPressable)); map->totalPressables=pressables; - map->dangers=malloc(gates*sizeof(tGate)); + map->dangers=malloc(dangers*sizeof(tDanger)); map->totalDangers=dangers; gates=0; pressables=0; @@ -146,6 +146,7 @@ void* mapLoadLevel(tMemory level) { pressableInRoom=0; dangerInRoom=0; } +printf("Map in memory\n"); /* read event list from file and convert it into the event array in memory */ for (i=0;i<256;i++) { @@ -159,6 +160,7 @@ void* mapLoadLevel(tMemory level) { map->events[i].gate=auxGates[(S-1)*30+L]; /* in case of error null is assigned */ } free(auxGates); +printf("Map loaded\n"); return (void*)map; } @@ -299,7 +301,7 @@ tRoom mapGetRoom(tMap* map, tRoomId roomAux) { * This will save a screen map modifiers into data. * * data and borders are in the same form as Walls but they contain - * additional modifiers that must be defined in maps.h. + * additional modifiers that must be defined in conf files. * e.g. MAPS_ITEMS_DOOROPEN 0x01 */ @@ -377,15 +379,46 @@ void mapMove(tMap* map) { break; } } + + /* check out and update all the spikes and choppers * + printf("updating\n"); + for (i=0;i<slevel(totalDangers);i++) { + printf("updating Spikes: action: %d frame=%d time=%d\n",map->dangers[i].action,map->dangers[i].frame,map->dangers[i].time); + switch (map->dangers[i].action) { + case eSpiUp: + map->dangers[i].frame++; + if (map->dangers[i].frame>3) { + map->dangers[i].frame=3; + map->dangers[i].action=eSpiWaitUp; + map->dangers[i].time=30; + } + break; + case eSpiWaitUp: + map->dangers[i].time--; + if (!map->dangers[i].time) { + map->dangers[i].action=eSpiDown; + } + break; + case eSpiDown: + if (map->dangers[i].frame) map->dangers[i].frame++; + if (map->dangers[i].frame==6) map->dangers[i].frame=0; + break; + default: + break; + } + }*/ } + void mapFreeLevel(tMap* map) { int i; for (i=0;i<24;i++) { free(map->screenGates[i]); free(map->screenPressables[i]); + /*free(map->screenDangers[i]);*/ } free(map->gates); free(map->pressables); + /*free(map->dangers);*/ free(map); }