void redraw_drawn_rectangle (struct drawn_rectangle *dr, struct pos *p, enum em em, enum vm vm) { if (dr->w <= 0 || dr->h <= 0) return; push_clipping_rectangle (dr->bitmap, dr->x, dr->y, dr->w, dr->h); struct coord tl, br; new_coord (&tl, &global_level, room_view, dr->x, dr->y); new_coord (&br, &global_level, room_view, dr->x + dr->w - 1, dr->y + dr->h - 1); struct pos ptl, pbr; posf (&tl, &ptl); posf (&br, &pbr); pos2room (&ptl, room_view, &ptl); pos2room (&pbr, room_view, &pbr); struct pos p0 = ptl; for (p0.floor = pbr.floor; p0.floor >= ptl.floor; p0.floor--) for (p0.place = ptl.place; p0.place <= pbr.place; p0.place++) if (! peq (&p0, p)) draw_confg (dr->bitmap, &p0, em, vm); pop_clipping_rectangle (); }
struct coord * p_spikes_right_01_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor + 44); }
struct coord * d_spikes_left_00_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 51); }
struct coord * mirror_reflex_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place + 3, PLACE_HEIGHT * p->floor + 6); }
struct coord * floor_reflex_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1) + 2, PLACE_HEIGHT * p->floor + 50); }
struct coord * blood_05_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place + 12, PLACE_HEIGHT * p->floor + 52); }
struct coord * pressed_closer_floor_left_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 51); }
struct coord * sword_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 50); }
struct coord * arch_top_left_end_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor + 3); }
struct coord * arch_top_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 10); }
struct coord * p_spikes_fg_01_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 48); }
struct coord * unpressed_opener_floor_right_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor + 50 - 1); }
static struct coord * guard_life_coord (int i, struct coord *c) { return new_coord (c, NULL, room_view, ORIGINAL_WIDTH - 7 * (i + 1) + 1, 194); }
struct coord * box_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor - 13); }
struct coord * door_left_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 3); }
struct coord * door_top_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor - 10); }
struct coord * door_grid_coord_base (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor - 6); }
struct coord * door_pole_base_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place + 24, PLACE_HEIGHT * (p->floor + 1) - 1); }
struct rect * new_rect (struct rect *r, int room, int x, int y, int w, int h) { new_coord (&r->c, &global_level, room, x, y); r->w = w; r->h = h; return r; }
struct coord * broken_floor_front_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place, PLACE_HEIGHT * p->floor + 54); }
struct coord * broken_floor_right_coord (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor + 49); }
struct coord * con_m (struct pos *p, struct coord *c) { return new_coord (c, p->l, p->room, PLACE_WIDTH * p->place + 15 + PLACE_WIDTH / 2, PLACE_HEIGHT * p->floor + 3 + PLACE_HEIGHT / 2); }
struct coord * _bf (struct frame *f, struct coord *c) { struct dim d; dim (f, &d); return new_coord (c, f->c.l, f->c.room, d.fx, d.y + d.h - 1); }
struct coord * door_grid_coord (struct pos *p, struct coord *c, int j, int i) { int r = i % 8; return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor - 6 + j * 8 + r + 1); }
struct coord * _tr (struct frame *f, struct coord *c) { struct dim d; dim (f, &d); return new_coord (c, f->c.l, f->c.room, d.x + d.w - 1, d.y); }
struct coord * _mba (struct frame *f, struct coord *c) { struct dim d; dim (f, &d); return new_coord (c, f->c.l, f->c.room, d.bx, d.y + d.h / 2); }
struct coord * _mbo (struct frame *f, struct coord *c) { struct dim d; dim (f, &d); return new_coord (c, f->c.l, f->c.room, d.x + d.w / 2, d.y + d.h - 1); }
struct coord * door_grid_tip_coord (struct pos *p, struct coord *c, int i) { int r = i % 8; int q = i / 8; return new_coord (c, p->l, p->room, PLACE_WIDTH * (p->place + 1), PLACE_HEIGHT * p->floor + 2 + q * 8 + r + 1); }
struct frame * place_frame (struct frame *f, struct frame *nf, ALLEGRO_BITMAP *b, struct pos *p, int dx, int dy) { struct pos pv; *nf = *f; pos2room (p, f->c.room, &pv); nf->b = b; new_coord (&nf->c, pv.l, pv.room, PLACE_WIDTH * pv.place + dx, PLACE_HEIGHT * pv.floor + dy); return nf; }
void print_success(latin_grid square) { if (square == square_B) { bool new_result = false; int row_repeats_A = repeat_count(diff_used_A); int row_repeats_B = repeat_count(diff_used_B); int AB_repeats = repeat_count(diff_used_diagonal_AB); int total_diagonal_repeats = AB_repeats + repeat_count(diff_used_diagonal_BA); if (row_repeats_A < least_row_repeats_A) { least_row_repeats_A = row_repeats_A; new_result = true; } if (row_repeats_B < least_row_repeats_B) { least_row_repeats_B = row_repeats_B; new_result = true; } if (AB_repeats < least_AB_repeats && least_row_repeats_A == row_repeats_A && least_row_repeats_B == row_repeats_B) { least_AB_repeats = AB_repeats; new_result = true; } if (total_diagonal_repeats < least_diagonal_repeats && least_row_repeats_A == row_repeats_A && least_row_repeats_B == row_repeats_B) { least_diagonal_repeats = total_diagonal_repeats; new_result = true; } if (verbose && new_result) { fill_in_square(square_A); fill_in_square(square_B); report2(square_A, square_B); } total_found++; } else { coord position = new_coord(); position->row = 0; position->col = 1; backtrack(square_B, position); } }