#include "game_types.h"

/* Image_DrawLineV @ 0x08013C28 (real 184B) -- display-pipe init with DMA and draw chain. Mirrors src/matched/Image_DrawLineV.c. */
/* Initializes the display pipe (control regs, table pointers, DMA of the
   zero word), stamps the draw-function table, then runs DrawBlended over
   0x02002CE0, FillRect, and the magic. Raw-decoded pools; the linear disasm
   hides two of them. */
extern void DMA_TransferWord(int dst, int *src, int ctrl);
extern void Image_DrawBlended(int *p);
extern void Image_FillRect(int x);

void Image_DrawLineV(int *p)
{
    int zero = 0;
    int r4;
    p[0] = 0;
    if (*(int *)0x040000C4 & 0x2000000)
        *(int *)0x040000C4 = 0x84400004;
    if (*(int *)0x040000D0 & 0x2000000)
        *(int *)0x040000D0 = 0x84400004;
    *(unsigned short *)0x040000C6 = 1024;
    *(unsigned short *)0x040000D2 = 1024;
    *(unsigned short *)0x04000884 = 143;
    *(unsigned short *)0x04000882 = 0xA90E;
    *(unsigned char *)0x04000089 =
        (*(unsigned char *)0x04000089 & 63) | 64;
    *(int **)0x040000BC = (int *)((char *)p + 848);
    *(int *)0x040000C0 = 0x04000A00;
    *(int **)0x040000C8 = (int *)((char *)p + 2432);
    *(int *)0x040000CC = 0x040000A4;
    *(int **)0x03007FF0 = p;
    DMA_TransferWord((int)&zero, p, 0x050003EC);
    ((unsigned char *)p)[6] = 8;
    ((unsigned char *)p)[7] = 15;
    p[14] = 0x080134B9;
    p[10] = 0x08014DD5;
    p[11] = 0x08014DD5;
    p[12] = 0x08014DD5;
    p[15] = 0x08014DD5;
    r4 = 0x02002CE0;
    Image_DrawBlended((int *)r4);
    p[13] = r4;
    Image_FillRect(0x40000);
    p[0] = 0x68736D53;
}
