#include "game_types.h"

/* Render_BitmapWithDMA @ 0x080037AC (real 74B) -- conditional bitmap draw + table-driven DMA. Mirrors src/matched/Render_BitmapWithDMA.c. */
/* Draws the bitmap when word 15 is set, then fires a 1024-unit DMA from
   the table-0x08028140 entry selected by the halfword at +134 to the VRAM
   target from table-0x08028170 selected by the halfword at +164. */
extern void Image_DrawBitmap(int a, int b, int c);
extern void DMA_TransferWord(int src, int dst, int ctrl);

void Render_BitmapWithDMA(int *p)
{
    int src, dst;
    if (p[15] != 0)
        Image_DrawBitmap(*(int *)0x080281C4, *(int *)0x0802819C, 0x2EB);
    src = *(int *)(*(int *)0x08028140 +
                   *(short *)((char *)p + 134) * 4);
    dst = (*(int *)(*(int *)0x08028170 +
                    *(short *)((char *)p + 164) * 4) << 11) + (192 << 19);
    DMA_TransferWord(src, dst, 1024);
}
