meter.c
3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**************************************************************************
* *
* 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);
}