--- /dev/null
+// WL_ACT1.C\r
+\r
+#include "WL_DEF.H"\r
+#pragma hdrstop\r
+\r
+/*\r
+=============================================================================\r
+\r
+ STATICS\r
+\r
+=============================================================================\r
+*/\r
+\r
+\r
+statobj_t statobjlist[MAXSTATS],*laststatobj;\r
+\r
+\r
+struct\r
+{\r
+ int picnum;\r
+ stat_t type;\r
+} statinfo[] =\r
+{\r
+{SPR_STAT_0}, // puddle spr1v\r
+{SPR_STAT_1,block}, // Green Barrel "\r
+{SPR_STAT_2,block}, // Table/chairs "\r
+{SPR_STAT_3,block}, // Floor lamp "\r
+{SPR_STAT_4}, // Chandelier "\r
+{SPR_STAT_5,block}, // Hanged man "\r
+{SPR_STAT_6,bo_alpo}, // Bad food "\r
+{SPR_STAT_7,block}, // Red pillar "\r
+//\r
+// NEW PAGE\r
+//\r
+{SPR_STAT_8,block}, // Tree spr2v\r
+{SPR_STAT_9}, // Skeleton flat "\r
+{SPR_STAT_10,block}, // Sink " (SOD:gibs)\r
+{SPR_STAT_11,block}, // Potted plant "\r
+{SPR_STAT_12,block}, // Urn "\r
+{SPR_STAT_13,block}, // Bare table "\r
+{SPR_STAT_14}, // Ceiling light "\r
+#ifndef SPEAR\r
+{SPR_STAT_15}, // Kitchen stuff "\r
+#else\r
+{SPR_STAT_15,block}, // Gibs!\r
+#endif\r
+//\r
+// NEW PAGE\r
+//\r
+{SPR_STAT_16,block}, // suit of armor spr3v\r
+{SPR_STAT_17,block}, // Hanging cage "\r
+{SPR_STAT_18,block}, // SkeletoninCage "\r
+{SPR_STAT_19}, // Skeleton relax "\r
+{SPR_STAT_20,bo_key1}, // Key 1 "\r
+{SPR_STAT_21,bo_key2}, // Key 2 "\r
+{SPR_STAT_22,block}, // stuff (SOD:gibs)\r
+{SPR_STAT_23}, // stuff\r
+//\r
+// NEW PAGE\r
+//\r
+{SPR_STAT_24,bo_food}, // Good food spr4v\r
+{SPR_STAT_25,bo_firstaid}, // First aid "\r
+{SPR_STAT_26,bo_clip}, // Clip "\r
+{SPR_STAT_27,bo_machinegun}, // Machine gun "\r
+{SPR_STAT_28,bo_chaingun}, // Gatling gun "\r
+{SPR_STAT_29,bo_cross}, // Cross "\r
+{SPR_STAT_30,bo_chalice}, // Chalice "\r
+{SPR_STAT_31,bo_bible}, // Bible "\r
+//\r
+// NEW PAGE\r
+//\r
+{SPR_STAT_32,bo_crown}, // crown spr5v\r
+{SPR_STAT_33,bo_fullheal}, // one up "\r
+{SPR_STAT_34,bo_gibs}, // gibs "\r
+{SPR_STAT_35,block}, // barrel "\r
+{SPR_STAT_36,block}, // well "\r
+{SPR_STAT_37,block}, // Empty well "\r
+{SPR_STAT_38,bo_gibs}, // Gibs 2 "\r
+{SPR_STAT_39,block}, // flag "\r
+//\r
+// NEW PAGE\r
+//\r
+#ifndef SPEAR\r
+{SPR_STAT_40,block}, // Call Apogee spr7v\r
+#else\r
+{SPR_STAT_40}, // Red light\r
+#endif\r
+//\r
+// NEW PAGE\r
+//\r
+{SPR_STAT_41}, // junk "\r
+{SPR_STAT_42}, // junk "\r
+{SPR_STAT_43}, // junk "\r
+#ifndef SPEAR\r
+{SPR_STAT_44}, // pots "\r
+#else\r
+{SPR_STAT_44,block}, // Gibs!\r
+#endif\r
+{SPR_STAT_45,block}, // stove " (SOD:gibs)\r
+{SPR_STAT_46,block}, // spears " (SOD:gibs)\r
+{SPR_STAT_47}, // vines "\r
+//\r
+// NEW PAGE\r
+//\r
+#ifdef SPEAR\r
+{SPR_STAT_48,block}, // marble pillar\r
+{SPR_STAT_49,bo_25clip}, // bonus 25 clip\r
+{SPR_STAT_50,block}, // truck\r
+{SPR_STAT_51,bo_spear}, // SPEAR OF DESTINY!\r
+#endif\r
+\r
+{SPR_STAT_26,bo_clip2}, // Clip "\r
+{-1} // terminator\r
+};\r
+\r
+/*\r
+===============\r
+=\r
+= InitStaticList\r
+=\r
+===============\r
+*/\r
+\r
+void InitStaticList (void)\r
+{\r
+ laststatobj = &statobjlist[0];\r
+}\r
+\r
+\r
+\r
+/*\r
+===============\r
+=\r
+= SpawnStatic\r
+=\r
+===============\r
+*/\r
+\r
+void SpawnStatic (int tilex, int tiley, int type)\r
+{\r
+ laststatobj->shapenum = statinfo[type].picnum;\r
+ laststatobj->tilex = tilex;\r
+ laststatobj->tiley = tiley;\r
+ laststatobj->visspot = &spotvis[tilex][tiley];\r
+\r
+ switch (statinfo[type].type)\r
+ {\r
+ case block:\r
+ (unsigned)actorat[tilex][tiley] = 1; // consider it a blocking tile\r
+ case dressing:\r
+ laststatobj->flags = 0;\r
+ break;\r
+\r
+ case bo_cross:\r
+ case bo_chalice:\r
+ case bo_bible:\r
+ case bo_crown:\r
+ case bo_fullheal:\r
+ if (!loadedgame)\r
+ gamestate.treasuretotal++;\r
+\r
+ case bo_firstaid:\r
+ case bo_key1:\r
+ case bo_key2:\r
+ case bo_key3:\r
+ case bo_key4:\r
+ case bo_clip:\r
+ case bo_25clip:\r
+ case bo_machinegun:\r
+ case bo_chaingun:\r
+ case bo_food:\r
+ case bo_alpo:\r
+ case bo_gibs:\r
+ case bo_spear:\r
+ laststatobj->flags = FL_BONUS;\r
+ laststatobj->itemnumber = statinfo[type].type;\r
+ break;\r
+ }\r
+\r
+ laststatobj++;\r
+\r
+ if (laststatobj == &statobjlist[MAXSTATS])\r
+ Quit ("Too many static objects!\n");\r
+}\r
+\r
+\r
+/*\r
+===============\r
+=\r
+= PlaceItemType\r
+=\r
+= Called during game play to drop actors' items. It finds the proper\r
+= item number based on the item type (bo_???). If there are no free item\r
+= spots, nothing is done.\r
+=\r
+===============\r
+*/\r
+\r
+void PlaceItemType (int itemtype, int tilex, int tiley)\r
+{\r
+ int type;\r
+ statobj_t *spot;\r
+\r
+//\r
+// find the item number\r
+//\r
+ for (type=0 ; ; type++)\r
+ {\r
+ if (statinfo[type].picnum == -1) // end of list\r
+ Quit ("PlaceItemType: couldn't find type!");\r
+ if (statinfo[type].type == itemtype)\r
+ break;\r
+ }\r
+\r
+//\r
+// find a spot in statobjlist to put it in\r
+//\r
+ for (spot=&statobjlist[0] ; ; spot++)\r
+ {\r
+ if (spot==laststatobj)\r
+ {\r
+ if (spot == &statobjlist[MAXSTATS])\r
+ return; // no free spots\r
+ laststatobj++; // space at end\r
+ break;\r
+ }\r
+\r
+ if (spot->shapenum == -1) // -1 is a free spot\r
+ break;\r
+ }\r
+//\r
+// place it\r
+//\r
+ spot->shapenum = statinfo[type].picnum;\r
+ spot->tilex = tilex;\r
+ spot->tiley = tiley;\r
+ spot->visspot = &spotvis[tilex][tiley];\r
+ spot->flags = FL_BONUS;\r
+ spot->itemnumber = statinfo[type].type;\r
+}\r
+\r
+\r
+\r
+/*\r
+=============================================================================\r
+\r
+ DOORS\r
+\r
+doorobjlist[] holds most of the information for the doors\r
+\r
+doorposition[] holds the amount the door is open, ranging from 0 to 0xffff\r
+ this is directly accessed by AsmRefresh during rendering\r
+\r
+The number of doors is limited to 64 because a spot in tilemap holds the\r
+ door number in the low 6 bits, with the high bit meaning a door center\r
+ and bit 6 meaning a door side tile\r
+\r
+Open doors conect two areas, so sounds will travel between them and sight\r
+ will be checked when the player is in a connected area.\r
+\r
+Areaconnect is incremented/decremented by each door. If >0 they connect\r
+\r
+Every time a door opens or closes the areabyplayer matrix gets recalculated.\r
+ An area is true if it connects with the player's current spor.\r
+\r
+=============================================================================\r
+*/\r
+\r
+#define DOORWIDTH 0x7800\r
+#define OPENTICS 300\r
+\r
+doorobj_t doorobjlist[MAXDOORS],*lastdoorobj;\r
+int doornum;\r
+\r
+unsigned doorposition[MAXDOORS]; // leading edge of door 0=closed\r
+ // 0xffff = fully open\r
+\r
+byte far areaconnect[NUMAREAS][NUMAREAS];\r
+\r
+boolean areabyplayer[NUMAREAS];\r
+\r
+\r
+/*\r
+==============\r
+=\r
+= ConnectAreas\r
+=\r
+= Scans outward from playerarea, marking all connected areas\r
+=\r
+==============\r
+*/\r
+\r
+void RecursiveConnect (int areanumber)\r
+{\r
+ int i;\r
+\r
+ for (i=0;i<NUMAREAS;i++)\r
+ {\r
+ if (areaconnect[areanumber][i] && !areabyplayer[i])\r
+ {\r
+ areabyplayer[i] = true;\r
+ RecursiveConnect (i);\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void ConnectAreas (void)\r
+{\r
+ memset (areabyplayer,0,sizeof(areabyplayer));\r
+ areabyplayer[player->areanumber] = true;\r
+ RecursiveConnect (player->areanumber);\r
+}\r
+\r
+\r
+void InitAreas (void)\r
+{\r
+ memset (areabyplayer,0,sizeof(areabyplayer));\r
+ areabyplayer[player->areanumber] = true;\r
+}\r
+\r
+\r
+\r
+/*\r
+===============\r
+=\r
+= InitDoorList\r
+=\r
+===============\r
+*/\r
+\r
+void InitDoorList (void)\r
+{\r
+ memset (areabyplayer,0,sizeof(areabyplayer));\r
+ _fmemset (areaconnect,0,sizeof(areaconnect));\r
+\r
+ lastdoorobj = &doorobjlist[0];\r
+ doornum = 0;\r
+}\r
+\r
+\r
+/*\r
+===============\r
+=\r
+= SpawnDoor\r
+=\r
+===============\r
+*/\r
+\r
+void SpawnDoor (int tilex, int tiley, boolean vertical, int lock)\r
+{\r
+ int areanumber;\r
+ unsigned far *map;\r
+\r
+ if (doornum==64)\r
+ Quit ("64+ doors on level!");\r
+\r
+ doorposition[doornum] = 0; // doors start out fully closed\r
+ lastdoorobj->tilex = tilex;\r
+ lastdoorobj->tiley = tiley;\r
+ lastdoorobj->vertical = vertical;\r
+ lastdoorobj->lock = lock;\r
+ lastdoorobj->action = dr_closed;\r
+\r
+ (unsigned)actorat[tilex][tiley] = doornum | 0x80; // consider it a solid wall\r
+\r
+//\r
+// make the door tile a special tile, and mark the adjacent tiles\r
+// for door sides\r
+//\r
+ tilemap[tilex][tiley] = doornum | 0x80;\r
+ map = mapsegs[0] + farmapylookup[tiley]+tilex;\r
+ if (vertical)\r
+ {\r
+ *map = *(map-1); // set area number\r
+ tilemap[tilex][tiley-1] |= 0x40;\r
+ tilemap[tilex][tiley+1] |= 0x40;\r
+ }\r
+ else\r
+ {\r
+ *map = *(map-mapwidth); // set area number\r
+ tilemap[tilex-1][tiley] |= 0x40;\r
+ tilemap[tilex+1][tiley] |= 0x40;\r
+ }\r
+\r
+ doornum++;\r
+ lastdoorobj++;\r
+}\r
+\r
+//===========================================================================\r
+\r
+/*\r
+=====================\r
+=\r
+= OpenDoor\r
+=\r
+=====================\r
+*/\r
+\r
+void OpenDoor (int door)\r
+{\r
+ if (doorobjlist[door].action == dr_open)\r
+ doorobjlist[door].ticcount = 0; // reset open time\r
+ else\r
+ doorobjlist[door].action = dr_opening; // start it opening\r
+}\r
+\r
+\r
+/*\r
+=====================\r
+=\r
+= CloseDoor\r
+=\r
+=====================\r
+*/\r
+\r
+void CloseDoor (int door)\r
+{\r
+ int tilex,tiley,area;\r
+ objtype *check;\r
+\r
+//\r
+// don't close on anything solid\r
+//\r
+ tilex = doorobjlist[door].tilex;\r
+ tiley = doorobjlist[door].tiley;\r
+\r
+ if (actorat[tilex][tiley])\r
+ return;\r
+\r
+ if (player->tilex == tilex && player->tiley == tiley)\r
+ return;\r
+\r
+ if (doorobjlist[door].vertical)\r
+ {\r
+ if ( player->tiley == tiley )\r
+ {\r
+ if ( ((player->x+MINDIST) >>TILESHIFT) == tilex )\r
+ return;\r
+ if ( ((player->x-MINDIST) >>TILESHIFT) == tilex )\r
+ return;\r
+ }\r
+ check = actorat[tilex-1][tiley];\r
+ if (check && ((check->x+MINDIST) >> TILESHIFT) == tilex )\r
+ return;\r
+ check = actorat[tilex+1][tiley];\r
+ if (check && ((check->x-MINDIST) >> TILESHIFT) == tilex )\r
+ return;\r
+ }\r
+ else if (!doorobjlist[door].vertical)\r
+ {\r
+ if (player->tilex == tilex)\r
+ {\r
+ if ( ((player->y+MINDIST) >>TILESHIFT) == tiley )\r
+ return;\r
+ if ( ((player->y-MINDIST) >>TILESHIFT) == tiley )\r
+ return;\r
+ }\r
+ check = actorat[tilex][tiley-1];\r
+ if (check && ((check->y+MINDIST) >> TILESHIFT) == tiley )\r
+ return;\r
+ check = actorat[tilex][tiley+1];\r
+ if (check && ((check->y-MINDIST) >> TILESHIFT) == tiley )\r
+ return;\r
+ }\r
+\r
+\r
+//\r
+// play door sound if in a connected area\r
+//\r
+ area = *(mapsegs[0] + farmapylookup[doorobjlist[door].tiley]\r
+ +doorobjlist[door].tilex)-AREATILE;\r
+ if (areabyplayer[area])\r
+ {\r
+ PlaySoundLocTile(CLOSEDOORSND,doorobjlist[door].tilex,doorobjlist[door].tiley); // JAB\r
+ }\r
+\r
+ doorobjlist[door].action = dr_closing;\r
+//\r
+// make the door space solid\r
+//\r
+ (unsigned)actorat[tilex][tiley]\r
+ = door | 0x80;\r
+}\r
+\r
+\r
+\r
+/*\r
+=====================\r
+=\r
+= OperateDoor\r
+=\r
+= The player wants to change the door's direction\r
+=\r
+=====================\r
+*/\r
+\r
+void OperateDoor (int door)\r
+{\r
+ int lock;\r
+\r
+ lock = doorobjlist[door].lock;\r
+ if (lock >= dr_lock1 && lock <= dr_lock4)\r
+ {\r
+ if ( ! (gamestate.keys & (1 << (lock-dr_lock1) ) ) )\r
+ {\r
+ SD_PlaySound (NOWAYSND); // locked\r
+ return;\r
+ }\r
+ }\r
+\r
+ switch (doorobjlist[door].action)\r
+ {\r
+ case dr_closed:\r
+ case dr_closing:\r
+ OpenDoor (door);\r
+ break;\r
+ case dr_open:\r
+ case dr_opening:\r
+ CloseDoor (door);\r
+ break;\r
+ }\r
+}\r
+\r
+\r
+//===========================================================================\r
+\r
+/*\r
+===============\r
+=\r
+= DoorOpen\r
+=\r
+= Close the door after three seconds\r
+=\r
+===============\r
+*/\r
+\r
+void DoorOpen (int door)\r
+{\r
+ if ( (doorobjlist[door].ticcount += tics) >= OPENTICS)\r
+ CloseDoor (door);\r
+}\r
+\r
+\r
+\r
+/*\r
+===============\r
+=\r
+= DoorOpening\r
+=\r
+===============\r
+*/\r
+\r
+void DoorOpening (int door)\r
+{\r
+ int area1,area2;\r
+ unsigned far *map;\r
+ long position;\r
+\r
+ position = doorposition[door];\r
+ if (!position)\r
+ {\r
+ //\r
+ // door is just starting to open, so connect the areas\r
+ //\r
+ map = mapsegs[0] + farmapylookup[doorobjlist[door].tiley]\r
+ +doorobjlist[door].tilex;\r
+\r
+ if (doorobjlist[door].vertical)\r
+ {\r
+ area1 = *(map+1);\r
+ area2 = *(map-1);\r
+ }\r
+ else\r
+ {\r
+ area1 = *(map-mapwidth);\r
+ area2 = *(map+mapwidth);\r
+ }\r
+ area1 -= AREATILE;\r
+ area2 -= AREATILE;\r
+ areaconnect[area1][area2]++;\r
+ areaconnect[area2][area1]++;\r
+ ConnectAreas ();\r
+ if (areabyplayer[area1])\r
+ {\r
+ PlaySoundLocTile(OPENDOORSND,doorobjlist[door].tilex,doorobjlist[door].tiley); // JAB\r
+ }\r
+ }\r
+\r
+//\r
+// slide the door by an adaptive amount\r
+//\r
+ position += tics<<10;\r
+ if (position >= 0xffff)\r
+ {\r
+ //\r
+ // door is all the way open\r
+ //\r
+ position = 0xffff;\r
+ doorobjlist[door].ticcount = 0;\r
+ doorobjlist[door].action = dr_open;\r
+ actorat[doorobjlist[door].tilex][doorobjlist[door].tiley] = 0;\r
+ }\r
+\r
+ doorposition[door] = position;\r
+}\r
+\r
+\r
+/*\r
+===============\r
+=\r
+= DoorClosing\r
+=\r
+===============\r
+*/\r
+\r
+void DoorClosing (int door)\r
+{\r
+ int area1,area2,move;\r
+ unsigned far *map;\r
+ long position;\r
+ int tilex,tiley;\r
+\r
+ tilex = doorobjlist[door].tilex;\r
+ tiley = doorobjlist[door].tiley;\r
+\r
+ if ( ((unsigned)actorat[tilex][tiley] != (door | 0x80))\r
+ || (player->tilex == tilex && player->tiley == tiley) )\r
+ { // something got inside the door\r
+ OpenDoor (door);\r
+ return;\r
+ };\r
+\r
+ position = doorposition[door];\r
+\r
+//\r
+// slide the door by an adaptive amount\r
+//\r
+ position -= tics<<10;\r
+ if (position <= 0)\r
+ {\r
+ //\r
+ // door is closed all the way, so disconnect the areas\r
+ //\r
+ position = 0;\r
+\r
+ doorobjlist[door].action = dr_closed;\r
+\r
+ map = mapsegs[0] + farmapylookup[doorobjlist[door].tiley]\r
+ +doorobjlist[door].tilex;\r
+\r
+ if (doorobjlist[door].vertical)\r
+ {\r
+ area1 = *(map+1);\r
+ area2 = *(map-1);\r
+ }\r
+ else\r
+ {\r
+ area1 = *(map-mapwidth);\r
+ area2 = *(map+mapwidth);\r
+ }\r
+ area1 -= AREATILE;\r
+ area2 -= AREATILE;\r
+ areaconnect[area1][area2]--;\r
+ areaconnect[area2][area1]--;\r
+\r
+ ConnectAreas ();\r
+ }\r
+\r
+ doorposition[door] = position;\r
+}\r
+\r
+\r
+\r
+\r
+/*\r
+=====================\r
+=\r
+= MoveDoors\r
+=\r
+= Called from PlayLoop\r
+=\r
+=====================\r
+*/\r
+\r
+void MoveDoors (void)\r
+{\r
+ int door;\r
+\r
+ if (gamestate.victoryflag) // don't move door during victory sequence\r
+ return;\r
+\r
+ for (door = 0 ; door < doornum ; door++)\r
+ switch (doorobjlist[door].action)\r
+ {\r
+ case dr_open:\r
+ DoorOpen (door);\r
+ break;\r
+\r
+ case dr_opening:\r
+ DoorOpening(door);\r
+ break;\r
+\r
+ case dr_closing:\r
+ DoorClosing(door);\r
+ break;\r
+ }\r
+}\r
+\r
+\r
+/*\r
+=============================================================================\r
+\r
+ PUSHABLE WALLS\r
+\r
+=============================================================================\r
+*/\r
+\r
+unsigned pwallstate;\r
+unsigned pwallpos; // amount a pushable wall has been moved (0-63)\r
+unsigned pwallx,pwally;\r
+int pwalldir;\r
+\r
+/*\r
+===============\r
+=\r
+= PushWall\r
+=\r
+===============\r
+*/\r
+\r
+void PushWall (int checkx, int checky, int dir)\r
+{\r
+ int oldtile;\r
+\r
+ if (pwallstate)\r
+ return;\r
+\r
+\r
+ oldtile = tilemap[checkx][checky];\r
+ if (!oldtile)\r
+ return;\r
+\r
+ switch (dir)\r
+ {\r
+ case di_north:\r
+ if (actorat[checkx][checky-1])\r
+ {\r
+ SD_PlaySound (NOWAYSND);\r
+ return;\r
+ }\r
+ (unsigned)actorat[checkx][checky-1] =\r
+ tilemap[checkx][checky-1] = oldtile;\r
+ break;\r
+\r
+ case di_east:\r
+ if (actorat[checkx+1][checky])\r
+ {\r
+ SD_PlaySound (NOWAYSND);\r
+ return;\r
+ }\r
+ (unsigned)actorat[checkx+1][checky] =\r
+ tilemap[checkx+1][checky] = oldtile;\r
+ break;\r
+\r
+ case di_south:\r
+ if (actorat[checkx][checky+1])\r
+ {\r
+ SD_PlaySound (NOWAYSND);\r
+ return;\r
+ }\r
+ (unsigned)actorat[checkx][checky+1] =\r
+ tilemap[checkx][checky+1] = oldtile;\r
+ break;\r
+\r
+ case di_west:\r
+ if (actorat[checkx-1][checky])\r
+ {\r
+ SD_PlaySound (NOWAYSND);\r
+ return;\r
+ }\r
+ (unsigned)actorat[checkx-1][checky] =\r
+ tilemap[checkx-1][checky] = oldtile;\r
+ break;\r
+ }\r
+\r
+ gamestate.secretcount++;\r
+ pwallx = checkx;\r
+ pwally = checky;\r
+ pwalldir = dir;\r
+ pwallstate = 1;\r
+ pwallpos = 0;\r
+ tilemap[pwallx][pwally] |= 0xc0;\r
+ *(mapsegs[1]+farmapylookup[pwally]+pwallx) = 0; // remove P tile info\r
+\r
+ SD_PlaySound (PUSHWALLSND);\r
+}\r
+\r
+\r
+\r
+/*\r
+=================\r
+=\r
+= MovePWalls\r
+=\r
+=================\r
+*/\r
+\r
+void MovePWalls (void)\r
+{\r
+ int oldblock,oldtile;\r
+\r
+ if (!pwallstate)\r
+ return;\r
+\r
+ oldblock = pwallstate/128;\r
+\r
+ pwallstate += tics;\r
+\r
+ if (pwallstate/128 != oldblock)\r
+ {\r
+ // block crossed into a new block\r
+ oldtile = tilemap[pwallx][pwally] & 63;\r
+\r
+ //\r
+ // the tile can now be walked into\r
+ //\r
+ tilemap[pwallx][pwally] = 0;\r
+ (unsigned)actorat[pwallx][pwally] = 0;\r
+ *(mapsegs[0]+farmapylookup[pwally]+pwallx) = player->areanumber+AREATILE;\r
+\r
+ //\r
+ // see if it should be pushed farther\r
+ //\r
+ if (pwallstate>256)\r
+ {\r
+ //\r
+ // the block has been pushed two tiles\r
+ //\r
+ pwallstate = 0;\r
+ return;\r
+ }\r
+ else\r
+ {\r
+ switch (pwalldir)\r
+ {\r
+ case di_north:\r
+ pwally--;\r
+ if (actorat[pwallx][pwally-1])\r
+ {\r
+ pwallstate = 0;\r
+ return;\r
+ }\r
+ (unsigned)actorat[pwallx][pwally-1] =\r
+ tilemap[pwallx][pwally-1] = oldtile;\r
+ break;\r
+\r
+ case di_east:\r
+ pwallx++;\r
+ if (actorat[pwallx+1][pwally])\r
+ {\r
+ pwallstate = 0;\r
+ return;\r
+ }\r
+ (unsigned)actorat[pwallx+1][pwally] =\r
+ tilemap[pwallx+1][pwally] = oldtile;\r
+ break;\r
+\r
+ case di_south:\r
+ pwally++;\r
+ if (actorat[pwallx][pwally+1])\r
+ {\r
+ pwallstate = 0;\r
+ return;\r
+ }\r
+ (unsigned)actorat[pwallx][pwally+1] =\r
+ tilemap[pwallx][pwally+1] = oldtile;\r
+ break;\r
+\r
+ case di_west:\r
+ pwallx--;\r
+ if (actorat[pwallx-1][pwally])\r
+ {\r
+ pwallstate = 0;\r
+ return;\r
+ }\r
+ (unsigned)actorat[pwallx-1][pwally] =\r
+ tilemap[pwallx-1][pwally] = oldtile;\r
+ break;\r
+ }\r
+\r
+ tilemap[pwallx][pwally] = oldtile | 0xc0;\r
+ }\r
+ }\r
+\r
+\r
+ pwallpos = (pwallstate/2)&63;\r
+\r
+}\r
+\r