#include "game_types.h"

/* Emitter_SpawnParticle @ 0x0800F97C (real 94B) -- kind dispatch into Sound_AddChannel. Mirrors src/matched/Emitter_SpawnParticle.c. */
/* Maps the byte at p[10] (76->1, 72->2, 82->0, else 3) and the eighths of the
   halfwords at p+4/p+6 into Sound_AddChannel(dst, kind, m, c, d). */
extern void Sound_AddChannel(int *dst, int kind, int m, int c, int d);

void Emitter_SpawnParticle(int a, short *p, int c, int d)
{
    unsigned char *b = (unsigned char *)p;
    int kind;
    int x, y;
    (void)a;
    if (b[10] == 76)
        kind = 1;
    else if (b[10] > 76)
        kind = b[10] == 82 ? 0 : 3;
    else
        kind = b[10] == 72 ? 2 : 3;
    x = p[2] / 8;
    y = p[3] / 8;
    Sound_AddChannel((int *)((char *)p + *(int *)((char *)p + 20)), kind, x * y, c, d);
}
