#include "game_types.h"

/* Sound_PlayChannelPattern @ 0x08010280 (real 42B) -- streams pattern bytes into channel halfwords. Mirrors src/matched/Sound_PlayChannelPattern.c. */
/* Streams pattern bytes: each nonzero byte indexes table[byte-32], ORs the
   pre-shifted bits, and stores a halfword; a zero byte ends the stream. */
void Sound_PlayChannelPattern(unsigned short *out, unsigned char *pat, int bits)
{
    unsigned b = *pat++;
    if (b == 0)
        return;
    {
        int *tab = (int *)0x0802A70C;
        int orr = bits << 12;
        do {
            *out++ = (unsigned short)(tab[b - 32] | orr);
            b = *pat++;
        } while (b != 0);
    }
}
