/*FILE HEADER**************************************************************
 *
 *  File name		: $Id$
 *  RCS Revision Number	: $Revision: 1.1 $
 *  Last Modified	: $Date: 94/10/28 09:23:28 $
 *  CSCI name		: Real-Time Graphics System - Applications Interface
 *  CSC name		: All functions
 *  Notes:
 *      This file contains code used to debug and test the SVME-770 RTGS.
 *      This code is provided as an example of how to call the RTGS functions
 *      from a host application.
 *  History		:
 *      Created 94/01/17 by Jeff Sanderson
 *
 *END FILE HEADER*********************************************************/

#include "dy4std.h"
#include "es.h"
#include "css.h"

#include "rtgs_ai.h"
#include "video.h"
#include "colours.h"

#include "test.h"


void time_blts( void );
/*-----------------------------------------------------------------------*/

void time_blts( void )
{
    int i;
    int frame_start;
    int frame_end;
    int time;
    float secs;
    int numvects;
    int *gcc_buf;
    video_params_t *gcc_vid;

    int pattern[] = {
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5,
        0xA5A5A5A5
    };


    init( "Bitblt benchmark" );
    gcc_vid = (video_params_t *)Gcc_malloc( sizeof(video_params_t), 0 );
    Get_video_mode( gcc_vid );
    Gcc_sync();
    gcc_vid->psize = 4;
    gcc_vid->scrn_pitch = 0x2000;
    Custom_initialize_video( gcc_vid );


    Clear_screen( BLACK, 0, 0 );
    Set_foreground_colour( WHITE );
    Printf("About to do 1000000 blts\n");

    gcc_buf = (int *)Gcc_malloc( sizeof(pattern), 0);
    Copy_bitmap_to_gcc( pattern, gcc_buf, sizeof(pattern));

    Key_wait();

    frame_start = FRAME_COUNT;
    for( i = 0; i < 1000000 ; i++ )
    {
#define BIT_EXPAND
#ifdef BIT_EXPAND
	Bitblt_bit_expand( gcc_buf, 100, 100, 16, 16, 16);
#endif
#ifdef L_XY
	Bitblt_linear_to_xy( gcc_buf, 100, 100, 16, 16, 16);
#endif
#ifdef XY_L
	Bitblt_xy_to_linear( 100, 100, gcc_buf, 16, 16, 16 );
#endif
#ifdef XY_XY
	Bitblt_xy_to_xy( 100, 100, 200, 200, 16, 16);
#endif
    }
    Gcc_sync();
    frame_end = FRAME_COUNT;
    time = frame_end - frame_start;
    secs = (float)((int)(time)) / 60.0;
    numvects = (int)((float)(1000000.0)/(float)(secs));

    Printf("Drew 1000000 blts in %d seconds\n",(int)(secs));
    Printf("Drew %d blts/sec\n",numvects);
    Key_wait();
}

/*-----------------------------------------------------------------------*/
