[go: up one dir, main page]

Menu

[r89]: / engine / bitmap_c.c  Maximize  Restore  History

Download this file

64 lines (46 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// bitmap_c.c The C versions of the bit-level routines
//
// defines
// Variables
int cmap_width; // Size of this map
int cmap_height;
int cmap_wxh; // Width x Height for speed
// Functions
void SetBit_C(int x,int y,char *collision_map);
void ResetBit_C(int x,int y,char *collision_map);
int GetBit_C(int x,int y,char *collision_map);
// Code
/*
* SetBit_C - Set the appropriate bit in the collision map
*/
void SetBit_C(int x,int y,char *collision_map)
{
int bitmap_pos;
unsigned char bitmask;
bitmap_pos = (y*cmap_width) + (x>>3);
bitmask = 1<<((unsigned char)x&7);
collision_map[bitmap_pos] |= bitmask;
}
/*
* ResetBit_C - Reset the appropriate bit in the collision map
*/
void ResetBit_C(int x,int y,char *collision_map)
{
int bitmap_pos;
unsigned char bitmask;
bitmap_pos = (y*cmap_width) + (x>>3);
bitmask = (1<<((unsigned char)x&7))^0xff;
collision_map[bitmap_pos] &= bitmask;
}
/*
* GetBit_C - Get the appropriate bit in the collision map
*/
int GetBit_C(int x,int y,char *collision_map)
{
int bitmap_pos;
unsigned char bitmask;
bitmap_pos = (y*cmap_width) + (x>>3);
bitmask = 1<<((unsigned char)x&7);
return (collision_map[bitmap_pos] & bitmask);
}