#include "game_types.h"

/* Level_InitEmitters @ 0x0800F38C (real 108B) -- inits emitter table from ROM blob 0x080D78D0. Mirrors src/matched/Level_InitEmitters.c. */
/* Loads the level blob, unpacks two LE32 params, inits sub-positions from
   p[16], draws the emitter at (120, 120), and updates sub-positions. */
extern void LoadLevelData(int *buf);
extern void InitSubPositions(int *buf, int x, int y);
extern void Emitter_DrawAt(int *base, int *buf, int x, int y);
extern void UpdateSubPositions(int *buf, int mode);

void Level_InitEmitters(int *p)
{
    int *base = *(int **)0x02000134;
    unsigned char *blob = *(unsigned char **)0x080D78D0;
    int buf[7];
    LoadLevelData(buf);
    buf[1] = 0x080D78D0;
    buf[2] = blob[4] | (blob[5] << 8) | (blob[6] << 16) | (blob[7] << 24);
    buf[3] = blob[8] | (blob[9] << 8) | (blob[10] << 16) | (blob[11] << 24);
    InitSubPositions(buf, p[16], 0);
    buf[0] = -1;
    Emitter_DrawAt(base, buf, 120, 120);
    UpdateSubPositions(buf, 2);
}
