#include "game_types.h"

/* Float_GetBuffer @ 0x0801ED64 (real 44B) -- rounds a float and repacks it for negate. Mirrors src/matched/Float_GetBuffer.c. */
/* Rounds the input into a 4-word buffer, repacks word 3 (shift/or pair),
   and forwards the buffer to Float_NegateIEEE. TODO(arity). */
extern void Float_Round(void *out, void *in);
extern int Float_NegateIEEE(int a, int b, int c, int d, int e);

int Float_GetBuffer(int v)
{
    int buf[5];
    buf[4] = v;
    Float_Round(&buf[1], &buf[4]);
    /* buf[0] = buf[3] >> 2 (logical); the r3<<=30 shift is dead (register
       only, never stored). The 5th NegateIEEE lane is stack residue in the
       asm; buf[4] stands in for it here. */
    buf[0] = (int)((unsigned)buf[3] >> 2);
    return Float_NegateIEEE(buf[0], buf[1], buf[2], buf[3], buf[4]);
}
