int postime(int dist) /* distance in sectors */ { int i, add = 0; int np = sizeof(postime_data) / sizeof(postime_data[0]) - 1; if (dist < 0) dist = -dist; if (dist <= postime_data[0].dist) return postime_data[0].time; if (dist > postime_data[np].dist) return postime_data[np].time; for (i = 0; i < np; i++) if (dist <= postime_data[i+1].dist) { return add + (((quad_t)(postime_data[i+1].dist-dist)) * postime_data[i].time + ((quad_t)(dist-postime_data[i].dist)) * postime_data[i+1].time) / (postime_data[i+1].dist - postime_data[i].dist); } printf("boom!\n"); return 0; }