#include "game_types.h"

/* Sub_0800D0D0 @ 0x0800D0D0 (real 150B) -- mode-dispatched pair check publishing to p[1]. Mirrors src/matched/Sub_0800D0D0.c. */
/* Zero word-4 selects the init block (flag 2 + preset quad). Otherwise the
   mode at base+0xA34 picks the pair-compare (mode 1/2/3 over the A38/A48
   quads, anything else true); when set, publishes [base+0x988] to p[1]. */
void Sub_0800D0D0(int *p)
{
    int *base = *(int **)0x02000134;
    int r;
    if (p[4] == 0) {
        int *q;
        *(int *)((char *)base + 0xA34) = 2;
        q = (int *)((char *)base + 0xA38);
        q[3] = 63;
        q[2] = 128;
        q[0] = 4096;
        q[1] = 0;
        return;
    }
    {
        int mode = *(int *)((char *)base + 0xA34);
        int *q = (int *)((char *)base + 0xA38);
        int *q2 = (int *)((char *)base + 0xA48);
        if (mode >= 1 && mode <= 3)
            r = q[0] == q[1] && q2[0] == q2[1];
        else
            r = 1;
    }
    if (((r << 24) & 0xFF000000) != 0)
        p[1] = *(int *)((char *)base + 0x988);
}
