35 #define CLEAR_CELLS(x, y, len_y) \
37 int clear_cells_i, j; \
38 memset(&the_map.cells[(x)][(y)], 0, sizeof(the_map.cells[(x)][(y)])*(len_y)); \
39 for (clear_cells_i = 0; clear_cells_i < (len_y); clear_cells_i++) \
41 for (j=0; j < MAXLAYERS; j++) { \
42 the_map.cells[(x)][(y)+clear_cells_i].heads[j].size_x = 1; \
43 the_map.cells[(x)][(y)+clear_cells_i].heads[j].size_y = 1; \
52 #define FOG_MAP_SIZE 512
58 #define FOG_BORDER_MIN 128
63 #define MAX_FACE_SIZE 16
70 #define CURRENT_MAX_VIEW 33
159 for (sdx=-1;sdx<2;sdx++)
160 for (sdy=-1;sdy<2;sdy++)
190 for (dx = 0; dx < w; dx++) {
191 for (dy = !dx; dy < h; dy++) {
280 for (dx = 0; dx < w; dx++) {
281 for (dy = !dx; dy < h; dy++) {
318 for (dx = 0; dx < w && dx <= x; dx++) {
319 for (dy = !dx; dy < h && dy <= y; dy++) {
321 assert(0 <= x-dx && x-dx <
MAX_VIEW);
322 assert(0 <= y-dy && y-dy <
MAX_VIEW);
335 if (0 <= x-dx && x-dx <
width
336 && 0 <= y-dy && y-dy <
height) {
339 if (set_need_update) {
370 head = &headcell->
head;
371 if (head->
face != 0) {
372 assert(headcell->
prev != NULL || headcell == bigfaces_head);
377 if (bigfaces_head == headcell) {
378 assert(headcell->
prev == NULL);
379 bigfaces_head = headcell->
next;
382 assert(headcell->
prev != NULL);
384 headcell->
prev = NULL;
385 headcell->
next = NULL;
390 assert(headcell->
prev == NULL && headcell != bigfaces_head);
391 assert(head->
size_x == 1);
392 assert(head->
size_y == 1);
416 head = &headcell->
head;
422 assert(headcell->
prev == NULL);
423 assert(headcell->
next == NULL);
424 assert(headcell != bigfaces_head);
425 if (bigfaces_head != NULL) {
426 assert(bigfaces_head->
prev == NULL);
427 bigfaces_head->
prev = headcell;
430 bigfaces_head = headcell;
440 for (dx = 0; dx < w && dx <= x; dx++) {
441 for (dy = !dx; dy < h && dy <= y; dy++) {
443 assert(0 <= x-dx && x-dx <
MAX_VIEW);
444 assert(0 <= y-dy && y-dy <
MAX_VIEW);
451 if (0 <= x-dx && x-dx <
width
452 && 0 <= y-dy && y-dy <
height) {
480 for (dx = 0; dx < w; dx++) {
481 for (dy = 0; dy < h; dy++) {
505 if (head->
face != 0) {
509 assert(head->
size_x == 1);
510 assert(head->
size_y == 1);
524 LOG(
LOG_ERROR,
"mapdata_init",
"%s\n",
"out of memory");
569 bigfaces_head = NULL;
589 return(x >= 0 && x < width && y >= 0 && y <
height);
667 if (!is_blank)
return;
713 static int dx[8]={0,1,1,1,0,-1,-1,-1};
714 static int dy[8]={-1,-1,0,1,1,1,0,-1};
715 int rx, ry, px, py, i;
805 int i, face, animation, phase, speed_left;
822 speed_left = anim_speed % random();
823 }
else if ((anim & ANIM_FLAGS_MASK) ==
ANIM_SYNC) {
871 for (cell = bigfaces_head; cell != NULL; cell = cell->
next) {
874 if (0 <= cell->
x-x && cell->
x-x <
width
875 && 0 <= cell->
y-y && cell->
y-y <
height) {
884 for (x = 0; x <
width; x++) {
885 for (y = 0; y <
height; y++) {
896 for (y = 0; y <
height; y++) {
904 for (y = 0; y <
height; y++) {
905 for (x = 0; x < -dx; x++) {
913 for (x = 0; x <
width; x++) {
921 for (x = 0; x <
width; x++) {
922 for (y = 0; y < -dy; y++) {
930 while (bigfaces_head != NULL) {
948 while (bigfaces_head != NULL) {
957 if (
width <= 0)
return(0);
959 assert(0 <= x && x <
width);
960 assert(0 <= y && y <
height);
970 if (
width <= 0)
return(0);
972 assert(0 <= x && x <
width);
973 assert(0 <= y && y <
height);
985 assert(0 <= dx && dx < w);
986 assert(0 <= dy && dy < h);
1015 if (!clear_bigface) {
1032 assert(0 <= dx && dx < w);
1033 assert(0 <= dy && dy < h);
1056 if (
width <= 0)
return(0);
1060 assert(0 <= layer && layer <
MAXLAYERS);
1087 int shift_x, shift_y;
1136 if (shift_x == 0 && shift_y == 0) {
1165 if (shift_x <= -FOG_MAP_SIZE || shift_x >=
FOG_MAP_SIZE
1166 || shift_y <= -FOG_MAP_SIZE || shift_y >=
FOG_MAP_SIZE) {
1204 for (sx = src_x, dx = dst_x, i = 0; i < len_x; sx++, dx++, i++) {
1211 else if (shift_x > 0) {
1212 for (sx = src_x+len_x-1, dx = dst_x+len_x-1, i = 0; i < len_x; sx--, dx--, i++) {
1220 assert(src_x == dst_x);
1221 for (dx = src_x, i = 0; i < len_x; dx++, i++) {
1230 for (dx = 0; dx < dst_x; dx++) {
1237 for (dx = 0; dx < len_x; dx++) {
1241 else if (shift_y < 0) {
1242 for (dx = 0; dx < len_x; dx++) {
1243 CLEAR_CELLS(dx+dst_x, FOG_MAP_SIZE+shift_y, -shift_y);
1266 int x,
y,
layer, face, smooth;
1296 for (layer=0; layer<
MAXLAYERS; layer++) {
Animations animations[MAXANIM]
void mapdata_set_anim_layer(int x, int y, uint16 anim, uint8 anim_speed, int layer)
void mapdata_animation(void)
#define CLEAR_CELLS(x, y, len_y)
void mapdata_set_check_space(int x, int y)
void mapdata_clear_space(int x, int y)
sint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh)
static void expand_clear_face(int x, int y, int w, int h, int layer)
struct MapCellLayer tails[MAXLAYERS]
sint16 want_config[CONFIG_NUMS]
static void expand_need_update(int x, int y, int w, int h)
static void expand_set_face(int x, int y, int layer, sint16 face, int clear)
#define CFG_LT_PIXEL_BEST
void mapdata_newmap(void)
static void expand_set_bigface(int x, int y, int layer, sint16 face, int clear)
static void expand_need_update_from_layer(int x, int y, int layer)
static void recenter_virtual_map_view(int diff_x, int diff_y)
void display_map_newmap(void)
void LOG(LogLevel level, const char *origin, const char *format,...)
static struct BigCell * bigfaces_head
sint16 use_config[CONFIG_NUMS]
static void mark_resmooth(int x, int y, int layer)
sint16 mapdata_face(int x, int y, int layer)
void mapdata_clear_old(int x, int y)
int display_mapscroll(int dx, int dy)
static void expand_clear_bigface_from_layer(int x, int y, int layer, int set_need_update)
void get_map_image_size(int face, uint8 *w, uint8 *h)
static void set_darkness(int x, int y, int darkness)
static void expand_clear_face_from_layer(int x, int y, int layer)
void mapdata_set_face_layer(int x, int y, sint16 face, int layer)
static void expand_clear_bigface(int x, int y, int w, int h, int layer, int set_need_update)
void mapdata_scroll(int dx, int dy)
sint16 mapdata_bigface(int x, int y, int layer, int *ww, int *hh)
int mapdata_is_inside(int x, int y)
static void mapdata_get_image_size(int face, uint8 *w, uint8 *h)
#define CONFIG_DISPLAYMODE
struct MapCellLayer heads[MAXLAYERS]
static struct BigCell bigfaces[MAX_VIEW][MAX_VIEW][MAXLAYERS]
void mapdata_set_size(int viewx, int viewy)
void mapdata_set_darkness(int x, int y, int darkness)
void mapdata_set_smooth(int x, int y, int smooth, int layer)