* Quadrant I (step < 0). */
| 1416 | * Quadrant I (step < 0). |
| 1417 | */ |
| 1418 | staticfn int |
| 1419 | _q1_path(int scol, int srow, int y2, int x2) |
| 1420 | { |
| 1421 | int dx, dy; |
| 1422 | int k, err, x, y, dxs, dys; |
| 1423 | |
| 1424 | x = scol; |
| 1425 | y = srow; |
| 1426 | dx = x2 - x; |
| 1427 | dy = y - y2; |
| 1428 | |
| 1429 | dxs = dx << 1; /* save the shifted values */ |
| 1430 | dys = dy << 1; |
| 1431 | if (dy > dx) { |
| 1432 | err = dxs - dy; |
| 1433 | |
| 1434 | for (k = dy - 1; k; k--) { |
| 1435 | if (err >= 0) { |
| 1436 | x++; |
| 1437 | err -= dys; |
| 1438 | } |
| 1439 | y--; |
| 1440 | err += dxs; |
| 1441 | if (!is_clear(y, x)) |
| 1442 | return 0; /* blocked */ |
| 1443 | } |
| 1444 | } else { |
| 1445 | err = dys - dx; |
| 1446 | |
| 1447 | for (k = dx - 1; k; k--) { |
| 1448 | if (err >= 0) { |
| 1449 | y--; |
| 1450 | err -= dxs; |
| 1451 | } |
| 1452 | x++; |
| 1453 | err += dys; |
| 1454 | if (!is_clear(y, x)) |
| 1455 | return 0; /* blocked */ |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | return 1; |
| 1460 | } |
| 1461 | |
| 1462 | /* |
| 1463 | * Quadrant IV (step > 0). |
nothing calls this directly
no outgoing calls
no test coverage detected