// SpectrumFile.vtx
// Author - MrC

const int STEP = 5;
float time = 0;

float tm;
int x,y;

float rx,ry,ryamt;
int currBuffer;

float[] buffers(24*32);
int counter = 0;

void Init()
{
	currBuffer = 0;
	counter = 0;
	for (int i=0; i<24*32; i++)
	{
		buffers[i]=0;
	}
	
	ryamt = -25.0f;
	ry = Rand() * 360.0f;

}

void Render()
{

	time += TIMEPASS;

	gfxTranslate(0,-2,30.0f);
	counter++;

	ryamt = (BASS) * 40;

	ry = ry + (ryamt*TIMEPASS);


	gfxRotate(-20,1,0,0);
	gfxRotate(ry,0,1,0);

	gfxSetBlendMode(BLEND_ADD);

	if (counter == 5)
	{
		currBuffer = (currBuffer+1) % 24;
		for (int i=0; i<32; i++)
		{
			buffers[currBuffer*32 + i] = GetSpec(i) * 4;
		}
		counter = 0;
	}

	gfxColour(1, 1, 1, 1);
	gfxSetLineWidth(5);

	for (int i=0; i<24;i++)
	{
		int index = (i+currBuffer+1) % 24;

		gfxBegin(PRIM_LINESTRIP);
		for (int x=0; x<32; x++)
		{
			gfxColour(i/24.0,x/32.0,1.0-(x/32.0),1.0); // fade colour
			gfxVertex(-12+i-(counter/5.0f), buffers[index*32 + x], -16+x);
		}
		gfxEnd();
	} 
}