]> 4ch.mooo.com Git - 16.git/blob - 16/sod8086/wl_act1.c
reference to the bbocg
[16.git] / 16 / sod8086 / wl_act1.c
1 // WL_ACT1.C\r
2 \r
3 #include "WL_DEF.H"\r
4 #pragma hdrstop\r
5 \r
6 /*\r
7 =============================================================================\r
8 \r
9                                                         STATICS\r
10 \r
11 =============================================================================\r
12 */\r
13 \r
14 \r
15 statobj_t       statobjlist[MAXSTATS],*laststatobj;\r
16 \r
17 \r
18 struct\r
19 {\r
20         int             picnum;\r
21         stat_t  type;\r
22 } statinfo[] =\r
23 {\r
24 {SPR_STAT_0},                                   // puddle          spr1v\r
25 {SPR_STAT_1,block},                             // Green Barrel    "\r
26 {SPR_STAT_2,block},                             // Table/chairs    "\r
27 {SPR_STAT_3,block},                             // Floor lamp      "\r
28 {SPR_STAT_4},                                   // Chandelier      "\r
29 {SPR_STAT_5,block},                             // Hanged man      "\r
30 {SPR_STAT_6,bo_alpo},                   // Bad food        "\r
31 {SPR_STAT_7,block},                             // Red pillar      "\r
32 //\r
33 // NEW PAGE\r
34 //\r
35 {SPR_STAT_8,block},                             // Tree            spr2v\r
36 {SPR_STAT_9},                                   // Skeleton flat   "\r
37 {SPR_STAT_10,block},                    // Sink            " (SOD:gibs)\r
38 {SPR_STAT_11,block},                    // Potted plant    "\r
39 {SPR_STAT_12,block},                    // Urn             "\r
40 {SPR_STAT_13,block},                    // Bare table      "\r
41 {SPR_STAT_14},                                  // Ceiling light   "\r
42 #ifndef SPEAR\r
43 {SPR_STAT_15},                                  // Kitchen stuff   "\r
44 #else\r
45 {SPR_STAT_15,block},                    // Gibs!\r
46 #endif\r
47 //\r
48 // NEW PAGE\r
49 //\r
50 {SPR_STAT_16,block},                    // suit of armor   spr3v\r
51 {SPR_STAT_17,block},                    // Hanging cage    "\r
52 {SPR_STAT_18,block},                    // SkeletoninCage  "\r
53 {SPR_STAT_19},                                  // Skeleton relax  "\r
54 {SPR_STAT_20,bo_key1},                  // Key 1           "\r
55 {SPR_STAT_21,bo_key2},                  // Key 2           "\r
56 {SPR_STAT_22,block},                    // stuff                                (SOD:gibs)\r
57 {SPR_STAT_23},                                  // stuff\r
58 //\r
59 // NEW PAGE\r
60 //\r
61 {SPR_STAT_24,bo_food},                  // Good food       spr4v\r
62 {SPR_STAT_25,bo_firstaid},              // First aid       "\r
63 {SPR_STAT_26,bo_clip},                  // Clip            "\r
64 {SPR_STAT_27,bo_machinegun},    // Machine gun     "\r
65 {SPR_STAT_28,bo_chaingun},              // Gatling gun     "\r
66 {SPR_STAT_29,bo_cross},                 // Cross           "\r
67 {SPR_STAT_30,bo_chalice},               // Chalice         "\r
68 {SPR_STAT_31,bo_bible},                 // Bible           "\r
69 //\r
70 // NEW PAGE\r
71 //\r
72 {SPR_STAT_32,bo_crown},                 // crown           spr5v\r
73 {SPR_STAT_33,bo_fullheal},              // one up          "\r
74 {SPR_STAT_34,bo_gibs},                  // gibs            "\r
75 {SPR_STAT_35,block},                    // barrel          "\r
76 {SPR_STAT_36,block},                    // well            "\r
77 {SPR_STAT_37,block},                    // Empty well      "\r
78 {SPR_STAT_38,bo_gibs},                  // Gibs 2          "\r
79 {SPR_STAT_39,block},                    // flag                         "\r
80 //\r
81 // NEW PAGE\r
82 //\r
83 #ifndef SPEAR\r
84 {SPR_STAT_40,block},                    // Call Apogee          spr7v\r
85 #else\r
86 {SPR_STAT_40},                                  // Red light\r
87 #endif\r
88 //\r
89 // NEW PAGE\r
90 //\r
91 {SPR_STAT_41},                                  // junk            "\r
92 {SPR_STAT_42},                                  // junk                    "\r
93 {SPR_STAT_43},                                  // junk            "\r
94 #ifndef SPEAR\r
95 {SPR_STAT_44},                                  // pots            "\r
96 #else\r
97 {SPR_STAT_44,block},                    // Gibs!\r
98 #endif\r
99 {SPR_STAT_45,block},                    // stove           " (SOD:gibs)\r
100 {SPR_STAT_46,block},                    // spears          " (SOD:gibs)\r
101 {SPR_STAT_47},                                  // vines                        "\r
102 //\r
103 // NEW PAGE\r
104 //\r
105 #ifdef SPEAR\r
106 {SPR_STAT_48,block},                    // marble pillar\r
107 {SPR_STAT_49,bo_25clip},                // bonus 25 clip\r
108 {SPR_STAT_50,block},                    // truck\r
109 {SPR_STAT_51,bo_spear},                 // SPEAR OF DESTINY!\r
110 #endif\r
111 \r
112 {SPR_STAT_26,bo_clip2},                 // Clip            "\r
113 {-1}                                                    // terminator\r
114 };\r
115 \r
116 /*\r
117 ===============\r
118 =\r
119 = InitStaticList\r
120 =\r
121 ===============\r
122 */\r
123 \r
124 void InitStaticList (void)\r
125 {\r
126         laststatobj = &statobjlist[0];\r
127 }\r
128 \r
129 \r
130 \r
131 /*\r
132 ===============\r
133 =\r
134 = SpawnStatic\r
135 =\r
136 ===============\r
137 */\r
138 \r
139 void SpawnStatic (int tilex, int tiley, int type)\r
140 {\r
141         laststatobj->shapenum = statinfo[type].picnum;\r
142         laststatobj->tilex = tilex;\r
143         laststatobj->tiley = tiley;\r
144         laststatobj->visspot = &spotvis[tilex][tiley];\r
145 \r
146         switch (statinfo[type].type)\r
147         {\r
148         case block:\r
149                 (unsigned)actorat[tilex][tiley] = 1;            // consider it a blocking tile\r
150         case dressing:\r
151                 laststatobj->flags = 0;\r
152                 break;\r
153 \r
154         case    bo_cross:\r
155         case    bo_chalice:\r
156         case    bo_bible:\r
157         case    bo_crown:\r
158         case    bo_fullheal:\r
159                 if (!loadedgame)\r
160                   gamestate.treasuretotal++;\r
161 \r
162         case    bo_firstaid:\r
163         case    bo_key1:\r
164         case    bo_key2:\r
165         case    bo_key3:\r
166         case    bo_key4:\r
167         case    bo_clip:\r
168         case    bo_25clip:\r
169         case    bo_machinegun:\r
170         case    bo_chaingun:\r
171         case    bo_food:\r
172         case    bo_alpo:\r
173         case    bo_gibs:\r
174         case    bo_spear:\r
175                 laststatobj->flags = FL_BONUS;\r
176                 laststatobj->itemnumber = statinfo[type].type;\r
177                 break;\r
178         }\r
179 \r
180         laststatobj++;\r
181 \r
182         if (laststatobj == &statobjlist[MAXSTATS])\r
183                 Quit ("Too many static objects!\n");\r
184 }\r
185 \r
186 \r
187 /*\r
188 ===============\r
189 =\r
190 = PlaceItemType\r
191 =\r
192 = Called during game play to drop actors' items.  It finds the proper\r
193 = item number based on the item type (bo_???).  If there are no free item\r
194 = spots, nothing is done.\r
195 =\r
196 ===============\r
197 */\r
198 \r
199 void PlaceItemType (int itemtype, int tilex, int tiley)\r
200 {\r
201         int                     type;\r
202         statobj_t       *spot;\r
203 \r
204 //\r
205 // find the item number\r
206 //\r
207         for (type=0 ;  ; type++)\r
208         {\r
209                 if (statinfo[type].picnum == -1)                // end of list\r
210                         Quit ("PlaceItemType: couldn't find type!");\r
211                 if (statinfo[type].type == itemtype)\r
212                         break;\r
213         }\r
214 \r
215 //\r
216 // find a spot in statobjlist to put it in\r
217 //\r
218         for (spot=&statobjlist[0] ; ; spot++)\r
219         {\r
220                 if (spot==laststatobj)\r
221                 {\r
222                         if (spot == &statobjlist[MAXSTATS])\r
223                                 return;                                                 // no free spots\r
224                         laststatobj++;                                          // space at end\r
225                         break;\r
226                 }\r
227 \r
228                 if (spot->shapenum == -1)                               // -1 is a free spot\r
229                         break;\r
230         }\r
231 //\r
232 // place it\r
233 //\r
234         spot->shapenum = statinfo[type].picnum;\r
235         spot->tilex = tilex;\r
236         spot->tiley = tiley;\r
237         spot->visspot = &spotvis[tilex][tiley];\r
238         spot->flags = FL_BONUS;\r
239         spot->itemnumber = statinfo[type].type;\r
240 }\r
241 \r
242 \r
243 \r
244 /*\r
245 =============================================================================\r
246 \r
247                                                         DOORS\r
248 \r
249 doorobjlist[] holds most of the information for the doors\r
250 \r
251 doorposition[] holds the amount the door is open, ranging from 0 to 0xffff\r
252         this is directly accessed by AsmRefresh during rendering\r
253 \r
254 The number of doors is limited to 64 because a spot in tilemap holds the\r
255         door number in the low 6 bits, with the high bit meaning a door center\r
256         and bit 6 meaning a door side tile\r
257 \r
258 Open doors conect two areas, so sounds will travel between them and sight\r
259         will be checked when the player is in a connected area.\r
260 \r
261 Areaconnect is incremented/decremented by each door. If >0 they connect\r
262 \r
263 Every time a door opens or closes the areabyplayer matrix gets recalculated.\r
264         An area is true if it connects with the player's current spor.\r
265 \r
266 =============================================================================\r
267 */\r
268 \r
269 #define DOORWIDTH       0x7800\r
270 #define OPENTICS        300\r
271 \r
272 doorobj_t       doorobjlist[MAXDOORS],*lastdoorobj;\r
273 int                     doornum;\r
274 \r
275 unsigned        doorposition[MAXDOORS];         // leading edge of door 0=closed\r
276                                                                                 // 0xffff = fully open\r
277 \r
278 byte            far areaconnect[NUMAREAS][NUMAREAS];\r
279 \r
280 boolean         areabyplayer[NUMAREAS];\r
281 \r
282 \r
283 /*\r
284 ==============\r
285 =\r
286 = ConnectAreas\r
287 =\r
288 = Scans outward from playerarea, marking all connected areas\r
289 =\r
290 ==============\r
291 */\r
292 \r
293 void RecursiveConnect (int areanumber)\r
294 {\r
295         int     i;\r
296 \r
297         for (i=0;i<NUMAREAS;i++)\r
298         {\r
299                 if (areaconnect[areanumber][i] && !areabyplayer[i])\r
300                 {\r
301                         areabyplayer[i] = true;\r
302                         RecursiveConnect (i);\r
303                 }\r
304         }\r
305 }\r
306 \r
307 \r
308 void ConnectAreas (void)\r
309 {\r
310         memset (areabyplayer,0,sizeof(areabyplayer));\r
311         areabyplayer[player->areanumber] = true;\r
312         RecursiveConnect (player->areanumber);\r
313 }\r
314 \r
315 \r
316 void InitAreas (void)\r
317 {\r
318         memset (areabyplayer,0,sizeof(areabyplayer));\r
319         areabyplayer[player->areanumber] = true;\r
320 }\r
321 \r
322 \r
323 \r
324 /*\r
325 ===============\r
326 =\r
327 = InitDoorList\r
328 =\r
329 ===============\r
330 */\r
331 \r
332 void InitDoorList (void)\r
333 {\r
334         memset (areabyplayer,0,sizeof(areabyplayer));\r
335         _fmemset (areaconnect,0,sizeof(areaconnect));\r
336 \r
337         lastdoorobj = &doorobjlist[0];\r
338         doornum = 0;\r
339 }\r
340 \r
341 \r
342 /*\r
343 ===============\r
344 =\r
345 = SpawnDoor\r
346 =\r
347 ===============\r
348 */\r
349 \r
350 void SpawnDoor (int tilex, int tiley, boolean vertical, int lock)\r
351 {\r
352         int     areanumber;\r
353         unsigned        far *map;\r
354 \r
355         if (doornum==64)\r
356                 Quit ("64+ doors on level!");\r
357 \r
358         doorposition[doornum] = 0;              // doors start out fully closed\r
359         lastdoorobj->tilex = tilex;\r
360         lastdoorobj->tiley = tiley;\r
361         lastdoorobj->vertical = vertical;\r
362         lastdoorobj->lock = lock;\r
363         lastdoorobj->action = dr_closed;\r
364 \r
365         (unsigned)actorat[tilex][tiley] = doornum | 0x80;       // consider it a solid wall\r
366 \r
367 //\r
368 // make the door tile a special tile, and mark the adjacent tiles\r
369 // for door sides\r
370 //\r
371         tilemap[tilex][tiley] = doornum | 0x80;\r
372         map = mapsegs[0] + farmapylookup[tiley]+tilex;\r
373         if (vertical)\r
374         {\r
375                 *map = *(map-1);                        // set area number\r
376                 tilemap[tilex][tiley-1] |= 0x40;\r
377                 tilemap[tilex][tiley+1] |= 0x40;\r
378         }\r
379         else\r
380         {\r
381                 *map = *(map-mapwidth);                                 // set area number\r
382                 tilemap[tilex-1][tiley] |= 0x40;\r
383                 tilemap[tilex+1][tiley] |= 0x40;\r
384         }\r
385 \r
386         doornum++;\r
387         lastdoorobj++;\r
388 }\r
389 \r
390 //===========================================================================\r
391 \r
392 /*\r
393 =====================\r
394 =\r
395 = OpenDoor\r
396 =\r
397 =====================\r
398 */\r
399 \r
400 void OpenDoor (int door)\r
401 {\r
402         if (doorobjlist[door].action == dr_open)\r
403                 doorobjlist[door].ticcount = 0;                 // reset open time\r
404         else\r
405                 doorobjlist[door].action = dr_opening;  // start it opening\r
406 }\r
407 \r
408 \r
409 /*\r
410 =====================\r
411 =\r
412 = CloseDoor\r
413 =\r
414 =====================\r
415 */\r
416 \r
417 void CloseDoor (int door)\r
418 {\r
419         int     tilex,tiley,area;\r
420         objtype *check;\r
421 \r
422 //\r
423 // don't close on anything solid\r
424 //\r
425         tilex = doorobjlist[door].tilex;\r
426         tiley = doorobjlist[door].tiley;\r
427 \r
428         if (actorat[tilex][tiley])\r
429                 return;\r
430 \r
431         if (player->tilex == tilex && player->tiley == tiley)\r
432                 return;\r
433 \r
434         if (doorobjlist[door].vertical)\r
435         {\r
436                 if ( player->tiley == tiley )\r
437                 {\r
438                         if ( ((player->x+MINDIST) >>TILESHIFT) == tilex )\r
439                                 return;\r
440                         if ( ((player->x-MINDIST) >>TILESHIFT) == tilex )\r
441                                 return;\r
442                 }\r
443                 check = actorat[tilex-1][tiley];\r
444                 if (check && ((check->x+MINDIST) >> TILESHIFT) == tilex )\r
445                         return;\r
446                 check = actorat[tilex+1][tiley];\r
447                 if (check && ((check->x-MINDIST) >> TILESHIFT) == tilex )\r
448                         return;\r
449         }\r
450         else if (!doorobjlist[door].vertical)\r
451         {\r
452                 if (player->tilex == tilex)\r
453                 {\r
454                         if ( ((player->y+MINDIST) >>TILESHIFT) == tiley )\r
455                                 return;\r
456                         if ( ((player->y-MINDIST) >>TILESHIFT) == tiley )\r
457                                 return;\r
458                 }\r
459                 check = actorat[tilex][tiley-1];\r
460                 if (check && ((check->y+MINDIST) >> TILESHIFT) == tiley )\r
461                         return;\r
462                 check = actorat[tilex][tiley+1];\r
463                 if (check && ((check->y-MINDIST) >> TILESHIFT) == tiley )\r
464                         return;\r
465         }\r
466 \r
467 \r
468 //\r
469 // play door sound if in a connected area\r
470 //\r
471         area = *(mapsegs[0] + farmapylookup[doorobjlist[door].tiley]\r
472                         +doorobjlist[door].tilex)-AREATILE;\r
473         if (areabyplayer[area])\r
474         {\r
475                 PlaySoundLocTile(CLOSEDOORSND,doorobjlist[door].tilex,doorobjlist[door].tiley); // JAB\r
476         }\r
477 \r
478         doorobjlist[door].action = dr_closing;\r
479 //\r
480 // make the door space solid\r
481 //\r
482         (unsigned)actorat[tilex][tiley]\r
483                 = door | 0x80;\r
484 }\r
485 \r
486 \r
487 \r
488 /*\r
489 =====================\r
490 =\r
491 = OperateDoor\r
492 =\r
493 = The player wants to change the door's direction\r
494 =\r
495 =====================\r
496 */\r
497 \r
498 void OperateDoor (int door)\r
499 {\r
500         int     lock;\r
501 \r
502         lock = doorobjlist[door].lock;\r
503         if (lock >= dr_lock1 && lock <= dr_lock4)\r
504         {\r
505                 if ( ! (gamestate.keys & (1 << (lock-dr_lock1) ) ) )\r
506                 {\r
507                         SD_PlaySound (NOWAYSND);                // locked\r
508                         return;\r
509                 }\r
510         }\r
511 \r
512         switch (doorobjlist[door].action)\r
513         {\r
514         case dr_closed:\r
515         case dr_closing:\r
516                 OpenDoor (door);\r
517                 break;\r
518         case dr_open:\r
519         case dr_opening:\r
520                 CloseDoor (door);\r
521                 break;\r
522         }\r
523 }\r
524 \r
525 \r
526 //===========================================================================\r
527 \r
528 /*\r
529 ===============\r
530 =\r
531 = DoorOpen\r
532 =\r
533 = Close the door after three seconds\r
534 =\r
535 ===============\r
536 */\r
537 \r
538 void DoorOpen (int door)\r
539 {\r
540         if ( (doorobjlist[door].ticcount += tics) >= OPENTICS)\r
541                 CloseDoor (door);\r
542 }\r
543 \r
544 \r
545 \r
546 /*\r
547 ===============\r
548 =\r
549 = DoorOpening\r
550 =\r
551 ===============\r
552 */\r
553 \r
554 void DoorOpening (int door)\r
555 {\r
556         int             area1,area2;\r
557         unsigned        far     *map;\r
558         long    position;\r
559 \r
560         position = doorposition[door];\r
561         if (!position)\r
562         {\r
563         //\r
564         // door is just starting to open, so connect the areas\r
565         //\r
566                 map = mapsegs[0] + farmapylookup[doorobjlist[door].tiley]\r
567                         +doorobjlist[door].tilex;\r
568 \r
569                 if (doorobjlist[door].vertical)\r
570                 {\r
571                         area1 = *(map+1);\r
572                         area2 = *(map-1);\r
573                 }\r
574                 else\r
575                 {\r
576                         area1 = *(map-mapwidth);\r
577                         area2 = *(map+mapwidth);\r
578                 }\r
579                 area1 -= AREATILE;\r
580                 area2 -= AREATILE;\r
581                 areaconnect[area1][area2]++;\r
582                 areaconnect[area2][area1]++;\r
583                 ConnectAreas ();\r
584                 if (areabyplayer[area1])\r
585                 {\r
586                         PlaySoundLocTile(OPENDOORSND,doorobjlist[door].tilex,doorobjlist[door].tiley);  // JAB\r
587                 }\r
588         }\r
589 \r
590 //\r
591 // slide the door by an adaptive amount\r
592 //\r
593         position += tics<<10;\r
594         if (position >= 0xffff)\r
595         {\r
596         //\r
597         // door is all the way open\r
598         //\r
599                 position = 0xffff;\r
600                 doorobjlist[door].ticcount = 0;\r
601                 doorobjlist[door].action = dr_open;\r
602                 actorat[doorobjlist[door].tilex][doorobjlist[door].tiley] = 0;\r
603         }\r
604 \r
605         doorposition[door] = position;\r
606 }\r
607 \r
608 \r
609 /*\r
610 ===============\r
611 =\r
612 = DoorClosing\r
613 =\r
614 ===============\r
615 */\r
616 \r
617 void DoorClosing (int door)\r
618 {\r
619         int             area1,area2,move;\r
620         unsigned        far     *map;\r
621         long    position;\r
622         int             tilex,tiley;\r
623 \r
624         tilex = doorobjlist[door].tilex;\r
625         tiley = doorobjlist[door].tiley;\r
626 \r
627         if ( ((unsigned)actorat[tilex][tiley] != (door | 0x80))\r
628         || (player->tilex == tilex && player->tiley == tiley) )\r
629         {                       // something got inside the door\r
630                 OpenDoor (door);\r
631                 return;\r
632         };\r
633 \r
634         position = doorposition[door];\r
635 \r
636 //\r
637 // slide the door by an adaptive amount\r
638 //\r
639         position -= tics<<10;\r
640         if (position <= 0)\r
641         {\r
642         //\r
643         // door is closed all the way, so disconnect the areas\r
644         //\r
645                 position = 0;\r
646 \r
647                 doorobjlist[door].action = dr_closed;\r
648 \r
649                 map = mapsegs[0] + farmapylookup[doorobjlist[door].tiley]\r
650                         +doorobjlist[door].tilex;\r
651 \r
652                 if (doorobjlist[door].vertical)\r
653                 {\r
654                         area1 = *(map+1);\r
655                         area2 = *(map-1);\r
656                 }\r
657                 else\r
658                 {\r
659                         area1 = *(map-mapwidth);\r
660                         area2 = *(map+mapwidth);\r
661                 }\r
662                 area1 -= AREATILE;\r
663                 area2 -= AREATILE;\r
664                 areaconnect[area1][area2]--;\r
665                 areaconnect[area2][area1]--;\r
666 \r
667                 ConnectAreas ();\r
668         }\r
669 \r
670         doorposition[door] = position;\r
671 }\r
672 \r
673 \r
674 \r
675 \r
676 /*\r
677 =====================\r
678 =\r
679 = MoveDoors\r
680 =\r
681 = Called from PlayLoop\r
682 =\r
683 =====================\r
684 */\r
685 \r
686 void MoveDoors (void)\r
687 {\r
688         int             door;\r
689 \r
690         if (gamestate.victoryflag)              // don't move door during victory sequence\r
691                 return;\r
692 \r
693         for (door = 0 ; door < doornum ; door++)\r
694                 switch (doorobjlist[door].action)\r
695                 {\r
696                 case dr_open:\r
697                         DoorOpen (door);\r
698                         break;\r
699 \r
700                 case dr_opening:\r
701                         DoorOpening(door);\r
702                         break;\r
703 \r
704                 case dr_closing:\r
705                         DoorClosing(door);\r
706                         break;\r
707                 }\r
708 }\r
709 \r
710 \r
711 /*\r
712 =============================================================================\r
713 \r
714                                                 PUSHABLE WALLS\r
715 \r
716 =============================================================================\r
717 */\r
718 \r
719 unsigned        pwallstate;\r
720 unsigned        pwallpos;                       // amount a pushable wall has been moved (0-63)\r
721 unsigned        pwallx,pwally;\r
722 int                     pwalldir;\r
723 \r
724 /*\r
725 ===============\r
726 =\r
727 = PushWall\r
728 =\r
729 ===============\r
730 */\r
731 \r
732 void PushWall (int checkx, int checky, int dir)\r
733 {\r
734         int             oldtile;\r
735 \r
736         if (pwallstate)\r
737           return;\r
738 \r
739 \r
740         oldtile = tilemap[checkx][checky];\r
741         if (!oldtile)\r
742                 return;\r
743 \r
744         switch (dir)\r
745         {\r
746         case di_north:\r
747                 if (actorat[checkx][checky-1])\r
748                 {\r
749                         SD_PlaySound (NOWAYSND);\r
750                         return;\r
751                 }\r
752                 (unsigned)actorat[checkx][checky-1] =\r
753                 tilemap[checkx][checky-1] = oldtile;\r
754                 break;\r
755 \r
756         case di_east:\r
757                 if (actorat[checkx+1][checky])\r
758                 {\r
759                         SD_PlaySound (NOWAYSND);\r
760                         return;\r
761                 }\r
762                 (unsigned)actorat[checkx+1][checky] =\r
763                 tilemap[checkx+1][checky] = oldtile;\r
764                 break;\r
765 \r
766         case di_south:\r
767                 if (actorat[checkx][checky+1])\r
768                 {\r
769                         SD_PlaySound (NOWAYSND);\r
770                         return;\r
771                 }\r
772                 (unsigned)actorat[checkx][checky+1] =\r
773                 tilemap[checkx][checky+1] = oldtile;\r
774                 break;\r
775 \r
776         case di_west:\r
777                 if (actorat[checkx-1][checky])\r
778                 {\r
779                         SD_PlaySound (NOWAYSND);\r
780                         return;\r
781                 }\r
782                 (unsigned)actorat[checkx-1][checky] =\r
783                 tilemap[checkx-1][checky] = oldtile;\r
784                 break;\r
785         }\r
786 \r
787         gamestate.secretcount++;\r
788         pwallx = checkx;\r
789         pwally = checky;\r
790         pwalldir = dir;\r
791         pwallstate = 1;\r
792         pwallpos = 0;\r
793         tilemap[pwallx][pwally] |= 0xc0;\r
794         *(mapsegs[1]+farmapylookup[pwally]+pwallx) = 0; // remove P tile info\r
795 \r
796         SD_PlaySound (PUSHWALLSND);\r
797 }\r
798 \r
799 \r
800 \r
801 /*\r
802 =================\r
803 =\r
804 = MovePWalls\r
805 =\r
806 =================\r
807 */\r
808 \r
809 void MovePWalls (void)\r
810 {\r
811         int             oldblock,oldtile;\r
812 \r
813         if (!pwallstate)\r
814                 return;\r
815 \r
816         oldblock = pwallstate/128;\r
817 \r
818         pwallstate += tics;\r
819 \r
820         if (pwallstate/128 != oldblock)\r
821         {\r
822         // block crossed into a new block\r
823                 oldtile = tilemap[pwallx][pwally] & 63;\r
824 \r
825                 //\r
826                 // the tile can now be walked into\r
827                 //\r
828                 tilemap[pwallx][pwally] = 0;\r
829                 (unsigned)actorat[pwallx][pwally] = 0;\r
830                 *(mapsegs[0]+farmapylookup[pwally]+pwallx) = player->areanumber+AREATILE;\r
831 \r
832                 //\r
833                 // see if it should be pushed farther\r
834                 //\r
835                 if (pwallstate>256)\r
836                 {\r
837                 //\r
838                 // the block has been pushed two tiles\r
839                 //\r
840                         pwallstate = 0;\r
841                         return;\r
842                 }\r
843                 else\r
844                 {\r
845                         switch (pwalldir)\r
846                         {\r
847                         case di_north:\r
848                                 pwally--;\r
849                                 if (actorat[pwallx][pwally-1])\r
850                                 {\r
851                                         pwallstate = 0;\r
852                                         return;\r
853                                 }\r
854                                 (unsigned)actorat[pwallx][pwally-1] =\r
855                                 tilemap[pwallx][pwally-1] = oldtile;\r
856                                 break;\r
857 \r
858                         case di_east:\r
859                                 pwallx++;\r
860                                 if (actorat[pwallx+1][pwally])\r
861                                 {\r
862                                         pwallstate = 0;\r
863                                         return;\r
864                                 }\r
865                                 (unsigned)actorat[pwallx+1][pwally] =\r
866                                 tilemap[pwallx+1][pwally] = oldtile;\r
867                                 break;\r
868 \r
869                         case di_south:\r
870                                 pwally++;\r
871                                 if (actorat[pwallx][pwally+1])\r
872                                 {\r
873                                         pwallstate = 0;\r
874                                         return;\r
875                                 }\r
876                                 (unsigned)actorat[pwallx][pwally+1] =\r
877                                 tilemap[pwallx][pwally+1] = oldtile;\r
878                                 break;\r
879 \r
880                         case di_west:\r
881                                 pwallx--;\r
882                                 if (actorat[pwallx-1][pwally])\r
883                                 {\r
884                                         pwallstate = 0;\r
885                                         return;\r
886                                 }\r
887                                 (unsigned)actorat[pwallx-1][pwally] =\r
888                                 tilemap[pwallx-1][pwally] = oldtile;\r
889                                 break;\r
890                         }\r
891 \r
892                         tilemap[pwallx][pwally] = oldtile | 0xc0;\r
893                 }\r
894         }\r
895 \r
896 \r
897         pwallpos = (pwallstate/2)&63;\r
898 \r
899 }\r
900 \r