display.c 2.11 KB
#include <stdio.h>

#include "acc_user.h"
#include "vcsuser.h"

FILE *OutFile;

void PrintTabHeader(char *prog_name)
{
    fprintf(OutFile, "#\n");
    fprintf(OutFile, "#   created by %s.c\n", prog_name);
    fprintf(OutFile, "#\n");
    fprintf(OutFile, "vclk                @C 1(8) 0(8)\n");
    fprintf(OutFile, "gamma_enable        @I @E 2\n");
    fprintf(OutFile, "gamma_dither_enable @I @E 2\n");
    fprintf(OutFile, "rgb[7:0]            @I @E 2\n");
    fprintf(OutFile, "rand[5:0]           @I @E 2\n");
    fprintf(OutFile, "sync                @I @E 2\n");

    fprintf(OutFile, "gamma_rgb           @O @S 15\n");
    fprintf(OutFile, "gamma_sync          @O @S 15\n");
    fprintf(OutFile, "\n"); /* required newline */
}

void open_out_file(void)
{
    char *filename;

    acc_initialize();
    acc_configure(accDevelopmentVersion, "1.6");

    if (tf_nump() != 1)
	{
	    tf_error("Illegal number of arguments to open_out_file");
	    tf_putp(0, -1);
	}
    else
	{
	    if ((filename = tf_getcstringp(1)) == NULL)
		{
		    tf_error("Illegal parameters passed to open_out_file");
		    tf_putp(0, -1);
		}
	    else
		{
		    if ((OutFile = fopen(filename, "w")) == NULL)
			{
			    tf_error("Couldn't open output file");
			    tf_putp(0, -1);
			}
		    PrintTabHeader("display");
		}
	}
    tf_putp(0, 0);
}

void output_gamma(void)
{
    int gamma_enable, gamma_dither_enable, rgb, vrand, sync, gamma_rgb, gamma_sync;

    if (OutFile != NULL)
	{
	    if (tf_nump() != 7)
		{
		    tf_error("Illegal number of arguments to output_gamma");
		    tf_putp(0, -1);
		}
	    else
		{
		    gamma_enable        = tf_getp(1);
		    gamma_dither_enable = tf_getp(2);
		    rgb                 = tf_getp(3);
		    vrand               = tf_getp(4);
		    sync                = tf_getp(5);
		    gamma_rgb           = tf_getp(6);
		    gamma_sync          = tf_getp(7);

		    fprintf(OutFile, "%d %d 0x%.2x 0x%.2x %d\t0x%.2x %d \n",
			    gamma_enable, gamma_dither_enable, rgb, vrand, sync, gamma_rgb, gamma_sync);
		}
	}

    tf_putp(0, 0);    
}

void close_output_files(void)
{
    if (OutFile != NULL) fclose(OutFile);

    tf_putp(0, 0);
}