#include "commun.h"

unsigned int IWRAM_CODE modulo(s32 i, u32 x, u32 y)
{

	//x%y
	u32 j;
	while ((y << i) == 0)
		i -= 2;
	for (; i >= 0; i -= 2)
	{
		j = y << i;
		while (x >= j)
		{
			x -= j;
		}
	}

	return x;
}

unsigned int IWRAM_CODE division(s32 i, u32 x, u32 y)
{

	//x%y
	u32 j, z = 0;
	while ((y << i) == 0)
		i -= 2;
	for (; i >= 0; i -= 2)
	{
		j = y << i;
		while (x >= j)
		{
			x -= j;
			z += 1 << i;
		}
	}

	return z;
}
