#include "vumanager.h"

CVU1MicroProgram::CVU1MicroProgram(uint64 * pCodeStart, uint64 * pCodeEnd, int Offset)
{
	// Create a static DMA segment that has an MPG vifcode followed by the
	// actual microcode data.

	m_pUploadPtr = VIFStaticDMA.GetPointer();
	m_iSize = pCodeEnd - pCodeStart;
	m_iOffset = Offset;

	VIFStaticDMA.StartMPG(Offset);

	for(int i = 0; i < m_iSize; i++)
	{
		VIFStaticDMA.AddMPG(pCodeStart[i]);
	}

	VIFStaticDMA.EndMPG();
	VIFStaticDMA.DMARet();
}

void CVU1MicroProgram::Upload()
{
	VIFDynamicDMA.Add32(FLUSHE);
	VIFDynamicDMA.DMACall(m_pUploadPtr);
}