=================================================================== RCS file: /cvs/ace/ace/lib/stack.c,v retrieving revision 1.1 retrieving revision 1.2 diff -p -u -r1.1 -r1.2 --- ace/lib/stack.c 1999/02/20 20:35:10 1.1 +++ /cvs/ace/ace/lib/stack.c 1999/02/20 20:36:47 1.2 @@ -17,6 +17,9 @@ #include #include +#include +#include +#include typedef struct Stack { struct Stack *prev, *next; @@ -673,24 +676,141 @@ stack_drop(Stack *onto, int n) } } +static int +isqrt(unsigned int i) +{ + unsigned int min = 0; + unsigned int max ; + for (max=1; max*maxnum_cards) + { + x2 += d->dx; + y2 += d->dy; + } + stack_begin_drag(s, sn-1, x1, y1); + flush(); + + /* 1 pixel per millisecond */ + dist = isqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); + dist /= 3; + + ox = y1; + oy = x1; + while (1) + { + now = ms_time(); + if (now == last) + { + ms_pause(); + continue; + } + + dx = (now - start) / dist; + if (dx >= 1) + break; + x = (int)(x1+dx*(x2-x1)); + y = (int)(y1+dx*(y2-y1)); + if (x != ox || y != oy) + { + stack_continue_drag(sn-1, x, y); + ox = x; + oy = y; + flush(); +#if 0 + frames++; +#endif + } + else + ms_pause(); + } + stack_drop(d, sn-1); + flush(); + now = ms_time(); + last = now - start; + if (last < 1) last = 1; +#if 0 + printf("%d frames in %d milliseconds = %g ms/f\n", + frames, last, (double)last/frames); +#endif +} + +#if 0 +void +old_stack_animate(Stack *s, Stack *d) +{ + int x1, y1, x2, y2, x, y, ox, oy; double dx, ddx; int sn, dn, frames=0; double start, end; @@ -702,13 +822,18 @@ stack_animate(Stack *s, Stack *d) dn = stack_count_cards(d); stack_card_posn(s, sn-1, &x1, &y1); stack_card_posn(d, dn-1, &x2, &y2); + if (d->num_cards) + { + x2 += d->dx; + y2 += d->dy; + } stack_begin_drag(s, sn-1, x1, y1); flush(); ddx = fps_factor/(iabs(x1-x2) + iabs(y1-y2)); if (ddx > 0.25) ddx = 0.25; ox = y1; oy = x1; - start = utime(); + start = ms_time(); for (dx=0; dx<1; dx+=ddx) { x = (int)(x1+dx*(x2-x1)); @@ -727,7 +852,7 @@ stack_animate(Stack *s, Stack *d) /* Figure out the new speed; we want the visual rate to be independent of the CPU/video performance */ - end = utime(); + end = ms_time(); if (end > start) { #if 0 @@ -746,3 +871,4 @@ stack_animate(Stack *s, Stack *d) } } +#endif