meter.c 3.07 KB
/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1995, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/

#include "spbench.h"

/*
 * meter.c
 *
 * Routines and display lists to display a simple meter across screen
 * for various events.
 */
#define METER_H 32
#define METER_V 16

static u32 meter_time;
static int meter_i,meter[7];

static Gfx meter_dl[]={
    gsDPPipeSync(),
    gsDPSetCycleType(G_CYC_FILL),
    gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(0,0,0,0)*0x10001),
    gsDPFillRectangle(METER_H-2,METER_V-2,METER_H+257,METER_V+3),
    gsDPPipeSync(),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(255,255,  0,0)*0x10001),
    gsDPFillRectangle(METER_H,METER_V,METER_H,METER_V),
    gsDPPipeSync(),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(255,  0,  0,0)*0x10001),
    gsDPFillRectangle(METER_H,METER_V,METER_H,METER_V),
    gsDPPipeSync(),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(  0,255,  0,0)*0x10001),
    gsDPFillRectangle(METER_H,METER_V,METER_H,METER_V),
    gsDPPipeSync(),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(  0,  0,255,0)*0x10001),
    gsDPFillRectangle(METER_H,METER_V,METER_H,METER_V),
    gsDPPipeSync(),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(255,255,255,0)*0x10001),
    gsDPFillRectangle(METER_H,METER_V,METER_H,METER_V),
    gsDPPipeSync(),
    gsDPSetFillColor((unsigned)GPACK_RGBA5551(  0,0,0,0)*0x10001),
    gsDPFillRectangle(METER_H,METER_V,METER_H,METER_V),
    gsDPPipeSync(),
    gsSPEndDisplayList()
};

/*
 * initialMeter
 *
 * Initialize various meter locations.
 */
void
initialMeter (void)
{
    meter[0]=METER_H;
    meter[1]=METER_H+231;
    meter[2]=METER_H+236;
    meter[3]=METER_H+241;
    meter[4]=METER_H+246;
    meter[5]=METER_H+251;
    meter[6]=METER_H+255;
    meter_time=osGetCount();
    meter_i=1;
}

/*
 * timeMeter
 *
 * Set current meter mark to current time and bump up the next meter mark.
 * If flag is zero, reset meter time and current mark.
 */
void
timeMeter(int flag)
{
    u32 temp;

    temp=osGetCount();
    meter[meter_i++]=METER_H+(temp-meter_time)/4096;
    if(flag==0) {
	meter_time=temp;
	meter_i=1;
    }
}

/*
 * graphMeter
 *
 * Display current meter.
 */
void
graphMeter(Gfx *dlp)
{
    int i,j;

    for(j=7,i=0;i!=6;j+=3,i++){
	gDPFillRectangle(&meter_dl[j],
		meter[i],METER_V,meter[i+1],METER_V+1);
    }
    gSPDisplayList(dlp, meter_dl);
}