#include <shinobi.h>
#include <kamui2.h>
#include <kmutil.h>
#include <string.h>
#include "dispstrex.h"
#include "command.h"

void MemCommand(int argc, char *argv[])
{
	Uint32 wholeFreeSize, biggestFreeBlockSize;
	KMSTATUS status;
	KMUINT32 FreeTexSize, MaxBlockSize;

	syMallocStat(&wholeFreeSize, &biggestFreeBlockSize);
	kmGetFreeTextureMem(&FreeTexSize, &MaxBlockSize);

	PRINTOUT(("[System Memory]\n"));
	if(strcmp(argv[1], "/H") == 0 || strcmp(argv[1], "/h") == 0)
	{
		PRINTOUT(("Whole Free System Memory = %8X[bytes]\n", wholeFreeSize));
		PRINTOUT(("Maximum Block Size = %8X[bytes]\n", biggestFreeBlockSize));
	}
	else
	{
		PRINTOUT(("Whole Free System Memory = %d[bytes]\n", wholeFreeSize));
		PRINTOUT(("Maximum Block Size = %d[bytes]\n", biggestFreeBlockSize));
	}

	PRINTOUT(("[Texture Memory]\n"));
	if(strcmp(argv[1], "/H") == 0 || strcmp(argv[1], "/h") == 0)
	{
		PRINTOUT(("Whole Free Texture Memory = %8X[bytes]\n", FreeTexSize));
		PRINTOUT(("Maximum Block Size = %8X[bytes]\n", MaxBlockSize));
	}
	else
	{
		PRINTOUT(("Whole Free Texture Memory = %d[bytes]\n", FreeTexSize));
		PRINTOUT(("Maximum Block Size = %d[bytes]\n", MaxBlockSize));
	}
}

void InitMemCommand(void)
{
	RegisterCommand(MemCommand, NULL, NULL, NULL, "mem");	/* Draw Command ‚Í–³‚µ */
}
