#include "game_types.h"

/* Sub_080060C4 @ 0x080060C4 (real 130B) -- mode-dispatched tile-row draw. Mirrors src/matched/Sub_080060C4.c. */
/* Dispatches on b with d >>= 4: mode 1 resolves the node through both
   lookup tables (3rd DrawTileRow arg is the base pool), mode 2 fans the
   counted rows, mode 0 indexes directly; otherwise returns. */
extern void Image_DrawTileRow_08013A1C(int a, int b, int c);

void Sub_080060C4(int a, int b, int c, int d)
{
    int e = d >> 4;
    int *node;
    (void)a;
    if (b == 1) {
        int k = *(int *)(0x08028C20 + c * 4);
        int h = *(unsigned short *)(0x081ADBB0 + k * 8 + 4);
        node = (int *)(0x081ADB14 + h * 12);
        Image_DrawTileRow_08013A1C(node[0], e & 0xFFFF, 0x081ADB14);
    } else if (b == 2) {
        int n = *(unsigned short *)0x08028C20;
        int *t = (int *)0x081ADB14;
        if (n == 0)
            return;
        while (n-- > 0) {
            Image_DrawTileRow_08013A1C(t[0], e & 0xFFFF, c);
            t = (int *)((char *)t + 12);
        }
    } else if (b == 0) {
        node = (int *)(0x081ADB14 + c * 12);
        Image_DrawTileRow_08013A1C(node[0], e & 0xFFFF, c);
    }
}
