#include "game_types.h"

/* Sub_08001510 @ 0x08001510 (real 60B) -- piecewise sprite-offset select on count and index. Mirrors src/matched/Sub_08001510.c. */
/* Piecewise offset select over the count word at +168 and the index:
   small counts interpolate around 238/240, large counts around 230/232. */
int Sub_08001510(int *p, int idx)
{
    int n = *(int *)((char *)p + 168);
    if (n <= 5) {
        if (idx < n)
            return (idx - n) * 8 + 238;
        return (idx - n) * 8 + 240;
    }
    if (idx != 0)
        return idx * 8 + 232;
    return 230 - (n > 9 ? 16 : 8);
}
