typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef int s32;

/* Simple functions that should match exactly */

/* 0x08000440 - already matched */
void SetObjectScreenPos(obj, x, y)
u32 *obj;
u32 x;
u32 y;
{
    obj[4] = x;
    obj[5] = y;
}

/* 0x08000ABC - need to fix encoding */
void Object_ClearState(obj)
u32 *obj;
{
    obj[0] = 0;
    obj[1] = 0;
    obj[2] = 0;
    obj[3] = 0;
    obj[4] = 0;
    obj[5] = 0;
}

/* 0x08000ACC - FreeIfFlagSet */
extern void free(void *ptr);
void FreeIfFlagSet(obj, flags)
void *obj;
u32 flags;
{
    if (flags & 1) {
        free(obj);
    }
}

/* 0x08005EB8 */
u32 Return_0C()
{
    return 0x0C;
}

/* 0x08005EBC */
u32 Return_1E()
{
    return 0x1E;
}

/* 0x08005EC0 */
void NopFunction()
{
}

/* Math functions */
u32 Math_Min(a, b)
u32 a;
u32 b;
{
    if (a < b) return a;
    return b;
}

u32 Math_Max(a, b)
u32 a;
u32 b;
{
    if (a > b) return a;
    return b;
}

s32 Math_Abs(val)
s32 val;
{
    if (val < 0) return -val;
    return val;
}

s32 Compare_Int(a, b)
u32 a;
u32 b;
{
    if (a > b) return 1;
    if (a < b) return -1;
    return 0;
}

/* Sound stubs */
void Sound_Play()
{
}

void Sound_StopAll()
{
}

/* Simple memory functions */
void Memory_Set(dst, val, count)
u8 *dst;
u8 val;
u32 count;
{
    while (count > 0) {
        *dst = val;
        dst++;
        count--;
    }
}

void Memory_Copy(dst, src, count)
u8 *dst;
u8 *src;
u32 count;
{
    while (count > 0) {
        *dst = *src;
        dst++;
        src++;
        count--;
    }
}
