DEADSOFTWARE

update copyrights
[flatwaifu.git] / src / bmap.c
1 /* Copyright (C) 1996-1997 Aleksey Volynskov
2 * Copyright (C) 2011 Rambo
3 * Copyright (C) 2020 SovietPony
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
18 #include <stdio.h>
19 #include "glob.h"
20 #include "view.h"
21 #include "bmap.h"
23 byte fld_need_remap=1;
25 byte bmap[FLDH/4][FLDW/4];
27 void BM_mark(obj_t *o,byte f) {
28 int x,y;
29 int xs,ys,xe,ye;
31 if((xs=(o->x-o->r)>>5)<0) xs=0;
32 if((xe=(o->x+o->r)>>5)>=FLDW/4) xe=FLDW/4-1;
33 if((ys=(o->y-o->h)>>5)<0) ys=0;
34 if((ye=o->y>>5)>=FLDH/4) ye=FLDH/4-1;
35 for(y=ys;y<=ye;++y)
36 for(x=xs;x<=xe;++x)
37 bmap[y][x]|=f;
38 }
40 void BM_clear(byte f)
41 {
42 int x,y;
43 for(x=0; x<FLDW/4; x++)
44 for (y=0; y<FLDH/4; y++)
45 bmap[y][x]&=~f;
46 }
48 void BM_remapfld(void)
49 {
50 BM_clear(BM_WALL);
51 int x,y;
52 for(x=0; x<FLDW; x++)
53 for(y=0; y<FLDH; y++)
54 if (fld[y][x] == 1 || fld[y][x] == 2)
55 bmap[y/4][x/4]|=BM_WALL;
56 fld_need_remap = 0;
57 }