shift pistol HUD sprite
[d2d-psx.git] / src / misc.c
blobb83b0cf6df59500cbfdeb9d763f65aedd5ffd957
1 /*
2 * Copyright (C) Prikol Software 1996-1997
3 * Copyright (C) Aleksey Volynskov 1996-1997
4 * Copyright (C) <ARembo@gmail.com> 2011
5 * Copyright (C) fgsfds 2019
7 * This file is part of the Doom2D PSX project.
9 * Doom2D PSX is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * Doom2D PSX is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/> or
20 * write to the Free Software Foundation, Inc.,
21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "glob.h"
25 #include <stdio.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include "files.h"
30 #include "memory.h"
31 #include "error.h"
32 #include "vga.h"
33 #include "sound.h"
34 #include "view.h"
35 #include "bmap.h"
36 #include "dots.h"
37 #include "monster.h"
38 #include "misc.h"
40 // #define WD 200
41 // #define HT 98
43 #define MAX_YV 30
45 #define MAXAIR 1091
47 extern dword walf[256];
49 byte z_dot = 0;
51 extern void * walp[256];
53 static void * sth[22], * bfh[160 - '!'], * sfh[160 - '!'], * bulsnd[2], * stone, * stone2, * keys[3], *hudmed, *hudarm[2];
54 static int prx = 0, pry = 0;
56 char vabuf[80] = { 0 };
58 int Z_sign(int a) {
59 if (a > 0)
60 return 1;
62 if (a < 0)
63 return -1;
65 return 0;
68 int Z_dec(int a, int b) {
69 if (abs(a) <= b)
70 return 0;
72 if (a > 0)
73 return a - b;
75 if (a < 0)
76 return a + b;
78 return 0;
81 void * Z_getspr(char n[4], int s, int d, char * dir) {
82 int h;
84 h = F_getsprid(n, s, d);
85 if (dir)
86 *dir = (h & 0x8000) ? 1 : 0;
87 return V_cachepic(M_lock(h));
90 void * Z_getsnd(char n[6]) {
91 char s[8];
92 strncpy(s + 2, n, 6);
93 s[0] = 'D';
94 s[1] = 'S';
95 return S_cachesound(M_lock(F_getresid(s)));
98 #define GAS_START (MN__LAST - MN_DEMON + 5)
99 #define GAS_TOTAL (MN__LAST - MN_DEMON + 16 + 10)
101 void Z_initst(void) {
102 int i;
103 char s[10];
104 static char nm[21][8] = {
105 "STTNUM0", "STTNUM1", "STTNUM2", "STTNUM3", "STTNUM4",
106 "STTNUM5", "STTNUM6", "STTNUM7", "STTNUM8", "STTNUM9",
107 "STTMINUS",
108 "FISTA0", "CSAWA0", "PISTA0", "SHOTA0", "SGN2A0", "MGUNA0","LAUNA0",
109 "PLASA0", "BFUGA0", "GUN2A0"
112 stone = V_cachepic(M_lock(F_getresid("STONE")));
113 stone2 = V_cachepic(M_lock(F_getresid("STONE2")));
114 keys[0] = V_cachepic(M_lock(F_getresid("KEYRA0")));
115 keys[1] = V_cachepic(M_lock(F_getresid("KEYGA0")));
116 keys[2] = V_cachepic(M_lock(F_getresid("KEYBA0")));
117 hudmed = V_cachepic(M_lock(F_getresid("MEDIA0")));
118 hudarm[0] = V_cachepic(M_lock(F_getresid("ARM1A0")));
119 hudarm[1] = V_cachepic(M_lock(F_getresid("ARM2A0")));
121 for (i = 0; i < 21; ++i)
122 sth[i] = V_cachepic(M_lock(F_getresid(nm[i])));
123 strcpy(s, "STBF_*");
124 for (i = '!'; i < 160; ++i) {
125 s[5] = i;
126 bfh[i - '!'] = V_cachepic(M_lock(F_findres(s)));
128 for (i = '!'; i < 160; ++i) {
129 sprintf(s, "STCFN%03d", i);
130 sfh[i - '!'] = V_cachepic(M_lock(F_findres(s)));
132 strcpy(s, "WINUM*");
133 for (i = '0'; i <= '9'; ++i) {
134 s[5] = i;
135 bfh[i - '!'] = V_cachepic(M_lock(F_getresid(s)));
137 bfh[':' - '!'] = V_cachepic(M_lock(F_getresid("WICOLON")));
138 bulsnd[0] = Z_getsnd("BUL1");
139 bulsnd[1] = Z_getsnd("BUL2");
140 } /* Z_initst */
142 void Z_putbfch(int c) {
143 cacheimg * p;
145 if ((c > 32) && (c < 160))
146 p = bfh[c - '!'];
147 else
148 p = NULL;
149 if (p) {
150 V_spr(prx, pry, p);
151 prx += p->img->w - 1;
152 } else {
153 prx += 12;
157 void Z_putsfch(int c) {
158 cacheimg * p;
160 if ((c > 32) && (c < 160))
161 p = sfh[c - '!'];
162 else
163 p = NULL;
164 if (p) {
165 V_spr(prx, pry, p);
166 prx += p->img->w - 1;
167 } else {
168 prx += 7;
172 void Z_gotoxy(int x, int y) {
173 prx = x;
174 pry = y;
177 void Z_printb(char * buf) {
178 int i;
179 for (i = 0; buf[i]; ++i) {
180 switch (buf[i]) {
181 case '\n':
182 pry += 13;
184 case '\r':
185 prx = 0;
186 break;
188 default:
189 Z_putbfch((byte) buf[i]);
194 int Z_linelens(char *buf) {
195 int i, x, c;
196 for (i = 0, x = 0; buf[i]; ++i) {
197 c = buf[i];
198 if ((c > 32) && (c < 160) && sfh[c - '!'])
199 x += ((cacheimg *)sfh[c - '!'])->img->w - 1;
200 else
201 x += 7;
203 return x;
206 int Z_linelenb(char *buf) {
207 int i, x, c;
208 for (i = 0, x = 0; buf[i]; ++i) {
209 c = buf[i];
210 if ((c > 32) && (c < 160) && bfh[c - '!'])
211 x += ((cacheimg *)bfh[c - '!'])->img->w - 1;
212 else
213 x += 12;
215 return x;
219 void Z_printsf(char * s, ...) {
220 int i;
221 va_list ap;
222 char buf[80];
224 va_start(ap, s);
225 vsprintf(buf, s, ap);
226 va_end(ap);
227 for (i = 0; buf[i]; ++i) {
228 switch (buf[i]) {
229 case '\n':
230 pry += 8;
232 case '\r':
233 prx = 0;
234 break;
236 default:
237 Z_putsfch((byte) buf[i]);
243 void Z_prints(char *buf) {
244 int i;
245 for (i = 0; buf[i]; ++i) {
246 switch (buf[i]) {
247 case '\n':
248 pry += 8;
250 case '\r':
251 prx = 0;
252 break;
254 default:
255 Z_putsfch((byte) buf[i]);
260 void Z_drawspr(int x, int y, void * p, char d) {
261 if (d)
262 V_spr2(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p); // if(d) V_spr2(x-w_x+100,y-w_y+HT/2+1+w_o,p);
263 else
264 V_spr(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p); // else V_spr(x-w_x+100,y-w_y+HT/2+1+w_o,p);
267 void Z_clrst(void) {
268 V_pic(SCRW - 120, w_o, stone); // V_pic(200,w_o,stone);
269 if (!_2pl)
270 V_pic(SCRW - 120, w_o + 120, stone2);
273 void Z_drawstkeys(byte k) {
274 int x, n;
276 //V_setrect(SCRW - 120, 70, w_o + 77, 23);
277 //Z_clrst(); // V_setrect(200,70,w_o+77,23);Z_clrst();
278 for (k >>= 4, n = 0, x = SCRW - 69; n < 3; ++n, k >>= 1, x += 9) { // for(k>>=4,n=0,x=245;n<3;++n,k>>=1,x+=9)
279 if (k & 1)
280 V_spr(x, w_o + 111, keys[n]);
284 void Z_drawstair(int a) {
285 //V_setrect(SCRW - 120, 120, w_o + 49, 2);
286 //Z_clrst(); // V_setrect(200,120,w_o+49,2);Z_clrst();
287 if (a <= 0)
288 return;
290 if (a > MAXAIR)
291 a = MAXAIR;
292 a = a * 100 / MAXAIR;
293 if (!a)
294 return;
296 V_clr(SCRW - 110, a, w_o + 58, 2, 0xC8); // V_clr(210,a,w_o+49,2,0xC8);
299 void Z_drawstprcnt(int y, int n) {
300 char s[20];
301 int l, i, x, c;
303 //V_setrect(SCRW - 120, 70, y * 19 + 7 + w_o, 19);
304 // Z_clrst(); // V_setrect(200,70,y*19+7+w_o,19);Z_clrst();
305 sprintf(s, "%3d", n);
306 l = strlen(s);
307 x = SCRW - 10 - l * 14; // l=strlen(s);x=210;
308 for (i = 0; i < l; ++i, x += 14) {
309 if ((s[i] >= '0') && (s[i] <= '9'))
310 c = s[i] - '0';
311 else if (s[i] == '-')
312 c = 10;
313 else
314 c = -1;
315 if (c >= 0)
316 V_spr(x, y * 19 + 12 + w_o, sth[c]);
320 void Z_drawstnum(int n) {
321 char s[20];
322 int l, i, x, c;
324 //V_setrect(SCRW - 50, 50, w_o + 77, 23);
325 // Z_clrst(); // V_setrect(270,50,w_o+77,23);Z_clrst();
326 if (!g_dm)
327 return;
329 sprintf(s, "%d", n);
330 l = strlen(s);
331 x = SCRW - 121 - l * 14; // l=strlen(s);x=(115-l*14)+200;
332 for (i = 0; i < l; ++i, x += 14) {
333 if ((s[i] >= '0') && (s[i] <= '9'))
334 c = s[i] - '0';
335 else if (s[i] == '-')
336 c = 10;
337 else
338 c = -1;
339 if (c >= 0)
340 V_spr(x, w_o + 2, sth[c]);
344 void Z_drawstwpn(int n, int a) {
345 char s[20];
346 int l, i, x, c;
348 i = n;
349 //V_setrect(SCRW - 120, 120, w_o + 58, 23);
350 // Z_clrst(); // V_setrect(200,120,w_o+58,23);Z_clrst();
351 if (i >= 0)
352 V_spr(SCRW - 88, w_o + 73 + 12, sth[i + 11]); // if(i>=0) V_spr(232,w_o+58+19,sth[i+12]);
353 if (n >= 2) {
354 sprintf(s, "%d", a);
355 l = strlen(s);
356 x = SCRW - 10 - l * 14; // l=strlen(s);x=310-l*14;
357 for (i = 0; i < l; ++i, x += 14) {
358 if ((s[i] >= '0') && (s[i] <= '9'))
359 c = s[i] - '0';
360 else if (s[i] == '-')
361 c = 10;
362 else
363 c = -1;
364 if (c >= 0)
365 V_spr(x, w_o + 73, sth[c]);
370 void Z_drawmanspr(int x, int y, void * p, char d, byte color) {
371 if (d)
372 V_manspr2(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p, color); // if(d) V_manspr2(x-w_x+100,y-w_y+HT/2+1+w_o,p,color);
373 else
374 V_manspr(x - w_x + WD / 2, y - w_y + HT / 2 + 1 + w_o, p, color); // else V_manspr(x-w_x+100,y-w_y+HT/2+1+w_o,p,color);
377 int Z_canstand(int x, int y, int r) {
378 int i;
380 i = (x - r) / CELW;
381 x = (x + r) / CELW;
382 y = (y + 1) / CELH;
383 if ((y >= FLDH) || (y < 0))
384 return 0;
386 if (i < 0)
387 i = 0;
388 if (x >= FLDW)
389 x = FLDW - 1;
390 for (; i <= x; ++i) {
391 if ((fld[y][i] == 1) || (fld[y][i] == 2) || (fld[y][i] == 4)) {
392 if (!z_dot)
393 return 1;
394 else if (!((walf[fldf[y][i]] | walf[fldb[y][i]]) & 2))
395 return 1;
398 return 0;
401 int Z_hitceil(int x, int y, int r, int h) {
402 int i;
404 i = (x - r) / CELW;
405 x = (x + r) / CELW;
406 y = (y - h + 1) / CELH;
407 if ((y >= FLDH) || (y < 0))
408 return 0;
410 if (i < 0)
411 i = 0;
412 if (x >= FLDW)
413 x = FLDW - 1;
414 for (; i <= x; ++i) {
415 if ((fld[y][i] == 1) || (fld[y][i] == 2)) {
416 if (!z_dot)
417 return 1;
418 else if (!((walf[fldf[y][i]] | walf[fldb[y][i]]) & 2))
419 return 1;
422 return 0;
425 int Z_canfit(int x, int y, int r, int h) {
426 int i, j, sx, sy;
428 sx = (x - r) / CELW;
429 sy = (y - h + 1) / CELH;
430 if (sx < 0)
431 sx = 0;
432 if (sy < 0)
433 sy = 0;
434 x = (x + r) / CELW;
435 y = (y - 0) / CELH;
436 if (x >= FLDW)
437 x = FLDW - 1;
438 if (y >= FLDH)
439 y = FLDH - 1;
440 for (i = sx; i <= x; ++i) {
441 for (j = sy; j <= y; ++j) {
442 if ((fld[j][i] == 1) || (fld[j][i] == 2)) {
443 if (!z_dot)
444 return 0;
445 else if (!((walf[fldf[j][i]] | walf[fldb[j][i]]) & 2))
446 return 0;
450 return 1;
453 int Z_inlift(int x, int y, int r, int h) {
454 int i, j, sx, sy;
456 sx = (x - r) / CELW;
457 sy = (y - h + 1) / CELH;
458 if (sx < 0)
459 sx = 0;
460 if (sy < 0)
461 sy = 0;
462 x = (x + r) / CELW;
463 y = (y - 1) / CELH;
464 if (x >= FLDW)
465 x = FLDW - 1;
466 if (y >= FLDH)
467 y = FLDH - 1;
468 for (i = sx; i <= x; ++i) {
469 for (j = sy; j <= y; ++j) {
470 if ((fld[j][i] == 9) || (fld[j][i] == 10))
471 return fld[j][i] - 8;
474 return 0;
477 int Z_isblocked(int x, int y, int r, int h, int xv) {
478 int i, j, sx, sy;
480 sx = (x - r) / CELW;
481 sy = (y - h + 1) / CELH;
482 if (sx < 0)
483 sx = 0;
484 if (sy < 0)
485 sy = 0;
486 x = (x + r) / CELW;
487 y = (y - 1) / CELH;
488 if (xv < 0)
489 x = sx;
490 else if (xv > 0)
491 sx = x;
492 if (x >= FLDW)
493 x = FLDW - 1;
494 if (y >= FLDH)
495 y = FLDH - 1;
496 for (i = sx; i <= x; ++i) {
497 for (j = sy; j <= y; ++j) {
498 if (fld[j][i] == 8)
499 return 1;
502 return 0;
503 } /* Z_isblocked */
505 int Z_istrapped(int x, int y, int r, int h) {
506 int i, j, sx, sy;
508 sx = (x - r) / CELW;
509 sy = (y - h + 1) / CELH;
510 if (sx < 0)
511 sx = 0;
512 if (sy < 0)
513 sy = 0;
514 x = (x + r) / CELW;
515 y = (y - 1) / CELH;
516 if (x >= FLDW)
517 x = FLDW - 1;
518 if (y >= FLDH)
519 y = FLDH - 1;
520 for (i = sx; i <= x; ++i) {
521 for (j = sy; j <= y; ++j) {
522 if (fld[j][i] == 255)
523 return 1;
526 return 0;
529 void Z_set_speed(obj_t * o, int s) {
530 int m;
532 if (!(m = max(abs(o->xv), abs(o->yv))))
533 m = 1;
534 o->xv = o->xv * s / m;
535 o->yv = o->yv * s / m;
538 static byte wfront;
540 int Z_inwater(int x, int y, int r, int h) {
541 int i, j, sx, sy;
543 sx = (x - r) / CELW;
544 sy = (y - h + 1) / CELH;
545 if (sx < 0)
546 sx = 0;
547 if (sy < 0)
548 sy = 0;
549 x = (x + r) / CELW;
550 y = (y - h / 2) / CELH;
551 if (x >= FLDW)
552 x = FLDW - 1;
553 if (y >= FLDH)
554 y = FLDH - 1;
555 for (i = sx; i <= x; ++i) {
556 for (j = sy; j <= y; ++j) {
557 if ((fld[j][i] >= 5) && (fld[j][i] <= 7)) {
558 wfront = fldf[j][i];
559 return 1;
563 return 0;
566 int Z_getacid(int x, int y, int r, int h) {
567 int i, j, sx, sy, a;
568 static byte tab[4] = { 0, 5, 10, 20 };
570 a = 0;
571 sx = (x - r) / CELW;
572 sy = (y - h + 1) / CELH;
573 if (sx < 0)
574 sx = 0;
575 if (sy < 0)
576 sy = 0;
577 x = (x + r) / CELW;
578 y = y / CELH;
579 if (x >= FLDW)
580 x = FLDW - 1;
581 if (y >= FLDH)
582 y = FLDH - 1;
583 for (i = sx; i <= x; ++i) {
584 for (j = sy; j <= y; ++j) {
585 if (fld[j][i] == 6)
586 a |= 1;
587 else if (fld[j][i] == 7)
588 a |= 2;
591 return tab[a];
594 int Z_canbreathe(int x, int y, int r, int h) {
595 int i, j, sx, sy;
597 sx = (x - r) / CELW;
598 sy = (y - h + 1) / CELH;
599 if (sx < 0)
600 sx = 0;
601 if (sy < 0)
602 sy = 0;
603 x = (x + r) / CELW;
604 y = (y - h / 2) / CELH;
605 if (x >= FLDW)
606 x = FLDW - 1;
607 if (y >= FLDH)
608 y = FLDH - 1;
609 if ((sx > x) || (sy > y))
610 return 1;
612 for (i = sx; i <= x; ++i) {
613 for (j = sy; j <= y; ++j) {
614 if ((fld[j][i] == 0) || (fld[j][i] == 3) || (fld[j][i] == 9) || (fld[j][i] == 10))
615 return 1;
618 return 0;
621 int Z_overlap(obj_t * a, obj_t * b) {
622 if (a->x - a->r > b->x + b->r)
623 return 0;
625 if (a->x + a->r < b->x - b->r)
626 return 0;
628 if (a->y <= b->y - b->h)
629 return 0;
631 if (a->y - a->h >= b->y)
632 return 0;
634 return 1;
637 void Z_kickobj(obj_t * o, int x, int y, int pwr) {
638 int dx, dy, m;
640 dx = o->x - x;
641 dy = o->y - o->h / 2 - y;
642 if (!(m = max(abs(dx), abs(dy))))
643 m = 1;
644 o->vx += (long) dx * pwr / m;
645 o->vy += (long) dy * pwr / m;
648 int Z_cansee(int x, int y, int xd, int yd) {
649 register dword d, m;
650 int sx, sy;
651 dword xe, ye, s, i;
653 if ((xd -= x) > 0)
654 sx = 1;
655 else if (xd < 0)
656 sx = -1;
657 else
658 sx = 0;
659 if ((yd -= y) > 0)
660 sy = 1;
661 else if (yd < 0)
662 sy = -1;
663 else
664 sy = 0;
665 if (!xd && !yd)
666 return 1;
668 if ((xd = abs(xd)) > (yd = abs(yd)))
669 d = xd;
670 else
671 d = yd;
672 xe = ye = 0;
673 for (i = 0; i <= d;) {
674 if ((x < 0) || (x >= FLDW * 8) || (y < 0) || (y >= FLDH * 8))
675 return 0;
677 if ((bmap[y >> 5][x >> 5] & BM_WALL)) {
678 if ((fld[y >> 3][x >> 3] == 1) || (fld[y >> 3][x >> 3] == 2))
679 return 0;
681 if ((xe += (xd << 3)) >= d) {
682 x += xe / d * sx;
683 xe = xe % d;
685 if ((ye += (yd << 3)) >= d) {
686 y += ye / d * sy;
687 ye = ye % d;
689 i += 8;
690 } else {
691 if (sx == 0) {
692 m = 0;
693 } else {
694 m = x & 31;
695 if (sx > 0)
696 m ^= 31;
697 ++m;
699 if (sy == 0) {
700 s = 0;
701 } else {
702 s = y & 31;
703 if (sy > 0)
704 s ^= 31;
705 ++s;
707 if (((s < m) && (s != 0)) || (m == 0))
708 m = s;
709 i += m;
710 x += (xd * m + xe) / d * sx;
711 xe = (xd * m + xe) % d;
712 y += (yd * m + ye) / d * sy;
713 ye = (yd * m + ye) % d;
716 return 1;
717 } /* Z_cansee */
719 int Z_look(obj_t * a, obj_t * b, int d) {
720 if (Z_sign(b->x - a->x) != d * 2 - 1)
721 return 0;
723 return Z_cansee(a->x, a->y - a->h / 2, b->x, b->y - b->h / 2);
726 #define wvel(v) if ((xv = abs(v) + 1) > 5) v = Z_dec (v, xv / 2 - 2)
728 byte z_mon = 0;
730 int Z_moveobj(obj_t * p) {
731 static int x, y, xv, yv, r, h, lx, ly, st;
732 static byte inw;
734 st = 0;
735 switch (Z_inlift(x = p->x, y = p->y, r = p->r, h = p->h)) {
736 case 0:
737 if (++p->yv > MAX_YV)
738 --p->yv;
739 break;
741 case 1:
742 if (--p->yv < -5)
743 ++p->yv;
744 break;
746 case 2:
747 if (p->yv > 5) {
748 --p->yv;
749 break;
751 ++p->yv;
752 break;
754 if ((inw = Z_inwater(x, y, r, h)) != 0) {
755 st |= Z_INWATER;
756 wvel(p->xv);
757 wvel(p->yv);
758 wvel(p->vx);
759 wvel(p->vy);
761 p->vx = Z_dec(p->vx, 1);
762 p->vy = Z_dec(p->vy, 1);
763 xv = p->xv + p->vx;
764 yv = p->yv + p->vy;
765 while (xv || yv) {
766 if ((x < -100) || (x >= FLDW * 8 + 100) || (y < -100) || (y >= FLDH * 8 + 100))
767 st |= Z_FALLOUT;
769 lx = x;
770 x += (abs(xv) <= 7) ? xv : ((xv > 0) ? 7 : -7);
771 if (z_mon) {
772 if (Z_isblocked(x, y, r, h, xv))
773 st |= Z_BLOCK;
775 if (!Z_canfit(x, y, r, h)) {
776 if (xv == 0)
777 x = lx;
778 else if (xv < 0)
779 x = ((lx - r) & 0xFFF8) + r;
780 else
781 x = ((lx + r) & 0xFFF8) - r + 7;
782 xv = p->xv = p->vx = 0;
783 st |= Z_HITWALL;
785 xv -= (abs(xv) <= 7) ? xv : ((xv > 0) ? 7 : -7);
787 ly = y;
788 y += (abs(yv) <= 7) ? yv : ((yv > 0) ? 7 : -7);
789 if (yv >= 8)
790 --y;
791 if ((yv < 0) && Z_hitceil(x, y, r, h)) {
792 y = ((ly - h + 1) & 0xFFF8) + h - 1;
793 yv = p->vy = 1;
794 p->yv = 0;
795 st |= Z_HITCEIL;
797 if ((yv > 0) && Z_canstand(x, y, r)) {
798 y = ((y + 1) & 0xFFF8) - 1;
799 yv = p->yv = p->vy = 0;
800 st |= Z_HITLAND;
802 yv -= (abs(yv) <= 7) ? yv : ((yv > 0) ? 7 : -7);
804 p->x = x;
805 p->y = y;
806 if (Z_inwater(x, y, r, h)) {
807 st |= Z_INWATER;
808 if (!inw)
809 st |= Z_HITWATER;
810 } else if (inw) {
811 st |= Z_HITAIR;
813 return st;
814 } /* Z_moveobj */
816 void Z_splash(obj_t * p, int n) {
817 Z_sound(bulsnd[0], 128);
818 DOT_water(p->x, p->y - p->h / 2, p->xv + p->vx, p->yv + p->vy, n,
819 (int) walp[wfront] - 1);
822 void Z_calc_time(dword t, word * h, word * m, word * s) {
823 t = t * FRAME_MSEC;
824 t = t / 1000;
825 *s = t % 60;
826 t = t - *s;
827 t = t / 60;
828 *m = t % 60;
829 t = t - *m;
830 t = t / 60;
831 *h = t;