DEADSOFTWARE

ccb44045d3bd976381bb72a1327471409553fb0d
[flatwaifu.git] / src / bmap.c
1 /*
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
23 #include "glob.h"
24 #include "view.h"
25 #include "bmap.h"
27 byte fld_need_remap=1;
29 byte bmap[FLDH/4][FLDW/4];
31 void BM_mark(obj_t *o,byte f) {
32 int x,y;
33 int xs,ys,xe,ye;
35 if((xs=(o->x-o->r)>>5)<0) xs=0;
36 if((xe=(o->x+o->r)>>5)>=FLDW/4) xe=FLDW/4-1;
37 if((ys=(o->y-o->h)>>5)<0) ys=0;
38 if((ye=o->y>>5)>=FLDH/4) ye=FLDH/4-1;
39 for(y=ys;y<=ye;++y)
40 for(x=xs;x<=xe;++x)
41 bmap[y][x]|=f;
42 }
44 void BM_clear(byte f)
45 {
46 int x,y;
47 for(x=0; x<FLDW/4; x++)
48 for (y=0; y<FLDH/4; y++)
49 bmap[y][x]&=~f;
50 }
52 void BM_remapfld(void)
53 {
54 BM_clear(BM_WALL);
55 int x,y;
56 for(x=0; x<FLDW; x++)
57 for(y=0; y<FLDH; y++)
58 if (fld[y][x] == 1 || fld[y][x] == 2)
59 bmap[y/4][x/4]|=BM_WALL;
60 fld_need_remap = 0;
61 }