- dirs = eye_to_cell_dir_ratio(dir, !indent, diff_y, -diff_x, 0,1,right);
- }
- else if (!strcmp(dir, "cx"))
- {
- dirs = eye_to_cell_dir_ratio(dir, indent, diff_y, diff_x, 1,0,right);
- }
- else if (!strcmp(dir, "sw"))
- {
- dirs = eye_to_cell_dir_ratio(dir, !indent, -diff_y, -diff_x, 0,0,right);
- }
- else if (!strcmp(dir, "ed"))
- {
- dirs = eye_to_cell_dir_ratio(dir, indent, -diff_y, diff_x, 0,1,right);
- }
- else if (!strcmp(dir, "we"))
- {
- dirs = eye_to_cell_dir_ratio(dir, indent, -diff_y, diff_x, 1,1,right);
- }
- return dirs;
-}
-
-
-
-static uint8_t is_top_left_shaded(uint16_t pos_a, uint16_t pos_b,
- int16_t a_y_on_left)
-{
- uint16_t start_last_row = world.map.length * (world.map.length - 1);
- uint8_t a_on_left_or_bottom = 0 <= a_y_on_left
- || (pos_a >= start_last_row);
- uint8_t b_on_top_or_right = pos_b < world.map.length
- || pos_b % world.map.length==world.map.length-1;
- return pos_a != pos_b && b_on_top_or_right && a_on_left_or_bottom;
-}
-
-
-
-static void fill_shadow(struct yx_uint8 * yx_eye, struct yx_uint8 * yx_cell,
- uint8_t * fov_map, uint16_t pos_a, uint16_t pos_b)
-{
- int16_t a_y_on_left = !(pos_a%world.map.length)? pos_a/world.map.length :-1;
- int16_t b_y_on_left = !(pos_b%world.map.length)? pos_b/world.map.length :-1;
- uint8_t top_left_shaded = is_top_left_shaded(pos_a, pos_b, a_y_on_left);
- uint16_t pos;
- uint8_t y, x, in_shade;
- for (y = 0; y < world.map.length; y++)
- {
- in_shade = (top_left_shaded || (b_y_on_left >= 0 && y > b_y_on_left))
- && (a_y_on_left < 0 || y < a_y_on_left);
- for (x = 0; x < world.map.length; x++)