#include "game_types.h"

/* Image_DrawStrip3 @ 0x080138FC (real 84B) -- strip dispatch with CheckState on negative. Mirrors src/matched/Image_DrawStrip3.c. */
/* Like DrawStrip2, but a negative (nonzero-halfword) tag word routes to
   Image_CheckState instead of SetMode. */
extern void BG_SetMode(int a, int b);
extern void Image_CheckState(int *node);

void Image_DrawStrip3(unsigned x)
{
    int *e = (int *)((char *)(int *)0x081ADBB0 + x * 4);
    unsigned h = *(unsigned short *)((char *)e + 4);
    int *node = *(int **)((char *)(int *)0x081ADB14 + h * 12);
    int tag = node[0];
    if (tag != e[0]) {
        BG_SetMode((int)node, e[0]);
        return;
    }
    {
        int t2 = node[1];
        if ((short)t2 == 0)
            BG_SetMode((int)node, tag);
        else if (t2 < 0)
            Image_CheckState(node);
    }
}
