#include "game_types.h"

/* Menu_Update @ 0x08007DC4 (real 144B) -- accumulates menu sprite offsets into a draw call. Mirrors src/matched/Menu_Update.c. */
/* Accumulates the sprite offsets: when the 0x2548 pair is both zero, folds
   the scaled 0x2558 product in (unless the 620/624 pair is also zero);
   otherwise adds the raw pair. Draws via Menu_Draw(p, s0, s1, 0). */
extern void Menu_Draw(int a, int b, int c, int d);

void Menu_Update(int *p)
{
    char *b = (char *)p;
    int s0 = *(int *)(b + 588);
    int s1 = *(int *)(b + 592);
    int *q = (int *)(b + 0x2548);
    if (q[0] == 0 && q[1] == 0) {
        int v0 = *(int *)(b + 620);
        if (v0 != 0 || *(int *)(b + 624) != 0) {
            int m = *(int *)(b + 0x2558);
            s0 += (*(int *)(b + 624)) * m;
            s1 += (*(int *)(b + 624)) * m;
        }
    } else {
        s0 += q[0];
        s1 += *(int *)(b + 0x254C);
    }
    Menu_Draw((int)p, s0, s1, 0);
}
