#include "main.h"

float l_fVUHeight[5];
uint l_uiVUImage = 0;

void InitVU(void)
{
    l_fVUHeight[0] = 0.0f;
    l_fVUHeight[1] = 0.0f;
    l_fVUHeight[2] = 0.0f;
    l_fVUHeight[3] = 0.0f;
    l_fVUHeight[4] = 0.0f;

//    l_uiVUImage = LoadTGAFile("letterbox.tga");
}

void DrawVU(void)
{
    glEnable(GL_BLEND);
//    glBindTexture(GL_TEXTURE_2D, l_uiVUImage);
    glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
    for(int t = 1; t < 6; ++t)
    {
        glLoadIdentity();        
        glTranslatef((t * 146.2f) + 73.1f, 0.0f, 0.0f);
        glBegin(GL_QUADS);
            glTexCoord2f(0.0f, 1.0f);
            glVertex2f(-73.1f, 0.0f);
            glTexCoord2f(1.0f, 1.0f);
            glVertex2f(73.1f, 0.0f);
            glTexCoord2f(1.0f, 0.0f);
            glVertex2f(73.1f, l_fVUHeight[t - 1]);
            glTexCoord2f(0.0f, 0.0f);
            glVertex2f(-73.1f, l_fVUHeight[t - 1]);
        glEnd();    

/*        glLoadIdentity();        
        glTranslatef((t * 204.8f) + 102.4f, g_iWinHeight, 0.0f);
        glBegin(GL_QUADS);
            glTexCoord2f(0.0f, 0.0f);
            glVertex2f(-102.4f, -l_fVUHeight[t]);
            glTexCoord2f(1.0f, 0.0f);
            glVertex2f(102.4f, -l_fVUHeight[t]);
            glTexCoord2f(1.0f, 1.0f);
            glVertex2f(102.4f, 0.0f);
            glTexCoord2f(0.0f, 1.0f);
            glVertex2f(-102.4f, 0.0f);
        glEnd();    */

        if(l_fVUHeight[t - 1] > 0.0f) l_fVUHeight[t - 1] -= 128.0f * g_fTimeMod;
    }
    glBindTexture(GL_TEXTURE_2D, 0);
}

void VUOnSound(unsigned char param)
{
    if(param > 5) return;
    l_fVUHeight[(int)param - 1] = 160.0f;
}
