#include "game_types.h"

/* Bignum_ApplyImpulse @ 0x0801C594 (real 48B) -- applies an impulse object, links the result node. Mirrors src/matched/Bignum_ApplyImpulse.c. */
/* Applies an impulse (index scaled by 88 plus 12) and links the result node
   (flag 0, index, self+12), then frees through the node+12 with the byte
   count. Returns NULL when the impulse produces nothing. */
extern int *Physics_ApplyImpulse(int ctx, int off);
extern void Physics_FreeAll(int *p, int zero, int off);

int *Bignum_ApplyImpulse(int ctx, int idx)
{
    int *r = Physics_ApplyImpulse(ctx, idx * 88 + 12);
    if (r == 0)
        return 0;
    r[0] = 0;
    r[1] = idx;
    r[2] = (int)r + 12;
    Physics_FreeAll((int *)((char *)r + 12), 0, idx * 88);
    return r;
}
