gng_report.c
7.67 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/**************************************************************************
* *
* Copyright (C) 1994, 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. *
* *
*************************************************************************/
/*
* File: gng_report.c
*
* Report diagnostic test status by generating a DL with sprite text data.
*
*/
#include <ultra64.h>
#include <assert.h>
#include <PR/ramrom.h>
#include "dldriver.h"
#include "font_ext.h"
#include "gng.h"
#include "../uji/uji_audio.h"
#define GLIST_LEN 2048
extern int sprintf(char *s, const char *fmt, ...);
extern OSMesgQueue dmaMessageQ, rspMessageQ, rdpMessageQ, retraceMessageQ;
extern OSMesg dmaMessageBuf, rspMessageBuf, rdpMessageBuf,
retraceMessageBuf;
extern OSMesg dummyMessage;
extern OSIoMesg dmaIOMessageBuf;
extern Dynamic dynamic;
extern int frame_count;
extern int module_num;
extern int rdp_DRAM_io;
extern int checksumRequest;
extern int rdp_regressionFlag;
extern int rdp_mspanFlushFlag;
extern int draw_buffer;
extern void *cfb_ptrs[];
extern int cfb_size;
extern int controlFrame;
extern int lastFrameNum;
extern int generateFullSync;
extern int controllerSlot;
extern int uselines;
extern u64 dram_stack[];
extern u64 dram_yield[];
extern u64 rdp_output_len;
extern u64 rdp_output[];
extern OSTask tlist;
extern char *staticSegment;
extern char *textureSegment;
extern Gfx *glistp;
/*
* Render a frame to the framebuffer with a string identifying the test,
* followed (in LARGE letters) the PASS/FAIL status of the test.
*/
void
gng_report( char *message, int testStatus, int flags, int delay)
{
int i;
OSTask *tlistp;
Dynamic *dynamicp;
int soundEffect = SOUND_NONE;
gngstatus *pstatus;
/*
* osAppNMIBuffer == 0x8000031c in locore rdram
*/
pstatus = (gngstatus *)osAppNMIBuffer;
/*
* set up pointers to build the display list.
*/
tlistp = &tlist;
dynamicp = &dynamic;
glistp = &(dynamicp->glist[0]);
/*
* Display 16 bit pixels.
*/
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
/*
* Tell RCP where each segment is
*/
gSPSegment(glistp++, 0, 0x0); /* K0 (physical) address segment */
gSPSegment(glistp++, STATIC_SEGMENT,
osVirtualToPhysical(staticSegment));
if (rdp_mspanFlushFlag) {
/*
* Force the pipeline to empty after the rendering of each
* display list item, to avoid incurring span buffer cache
* coherency problems with DRAM r-m-w cycles.
*/
gDPPipelineMode(glistp++, G_PM_1PRIMITIVE);
}
gSPDisplayList(glistp++, rdpinit_dl);
gSPDisplayList(glistp++, rspinit_dl);
/*
* If the rdp_regressionFlag is set, apply a 1/4 shrink to the
* viewport so that the tests will render more quickly (because they
* won't be as fill limited). Do this after we invoke the display
* list pointed to by setup_rspstate.
*/
if (rdp_regressionFlag) {
gSPDisplayList(glistp++, regression_viewport);
}
/*
* 16 bit rendering. Width of Z buffer is determined
* by width of color frame buffer.
*/
gDPSetDepthImage( glistp++, zbuffer );
gDPPipeSync(glistp++);
gDPSetColorImage( glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b,
SCREEN_WD, OS_K0_TO_PHYSICAL(cfb_16_a) );
gDPPipeSync(glistp++);
gSPDisplayList(glistp++, clearcfb_dl);
font_init( &glistp ); /* Initialize fonts */
gDPSetBlendColor( glistp++, 0, 0, 0, 0 );
gDPSetAlphaCompare( glistp++, G_AC_THRESHOLD );
font_set_pos( 50, 40 ); /* Setup where and how to draw text */
font_set_color( 55, 55, 255, 255 );
font_set_scale( 1.0, 1.0 );
font_set_win( 27, 7 );
font_show_string( &glistp, message);
if(flags & GNG_PASS_FAIL_BIT) {
/*
* For standard tests, show "PASS" at the current text position.
* For the final 'PASS', display the "PASS" in large green letters.
*
* Also play a tune for the final 'PASS', and a nasty tone for
* any 'FAIL' messages.
*/
if (testStatus == 0) {
if (flags & GNG_FINAL_TEST_BIT) {
font_set_pos( 60, 100 );
font_set_win( 5, 3 );
font_set_scale( 6.0, 6.0 ); /* BIG */
/*
* Check to see if any tests failed during the sequence.
*/
if (pstatus->testFailed == 0) {
font_set_color( 8, 255, 8, 255 ); /* GREEN */
font_show_string( &glistp, "PASS" );
soundEffect = SOUND_PASS;
} else {
font_set_color( 255, 8, 8, 255 ); /* RED */
font_show_string( &glistp, "FAIL" );
soundEffect = SOUND_FAIL;
}
} else {
font_set_color( 8, 255, 8, 255 ); /* GREEN */
font_show_string( &glistp, "PASS" );
}
} else {
font_set_pos( 50, 180 );
font_show_string( &glistp, "Press yellow button\nto continue..." );
font_set_pos( 60, 100 );
font_set_win( 5, 3 );
font_set_scale( 6.0, 6.0 ); /* BIG */
font_set_color( 255, 8, 8, 255 ); /* RED */
font_show_string( &glistp, "FAIL" );
soundEffect = SOUND_FAIL;
}
}
font_finish( &glistp );
/*
* Complete the display list, then render to the framebuffer.
*/
gDPFullSync(glistp++);
gSPEndDisplayList(glistp++);
assert((glistp-dynamicp->glist) < GLIST_LEN);
/*
* Build graphics task:
*
*/
tlistp->t.ucode_boot = (u64 *) rspbootTextStart;
tlistp->t.ucode_boot_size = (u32)rspbootTextEnd - (u32)rspbootTextStart;
/*
* Use RSP ucode which outputs over XBUS to RDP:
*/
tlistp->t.ucode = (u64 *) gspFast3DTextStart;
tlistp->t.ucode_data = (u64 *) gspFast3DDataStart;
/* initial display list: */
tlistp->t.data_ptr = (u64 *) dynamicp->glist;
tlistp->t.data_size = (u32)((glistp - dynamicp->glist) * sizeof(Gfx));
/*
* Write back dirty cache lines that need to be read by the RCP.
*/
osWritebackDCache(&dynamic, sizeof(dynamic));
/*
* start up the RSP task
*/
osSpTaskStart(tlistp);
/* wait for SP completion */
(void)osRecvMesg(&rspMessageQ, NULL, OS_MESG_BLOCK);
(void)osRecvMesg(&rdpMessageQ, NULL, OS_MESG_BLOCK);
/* swap buffers, to display what we rendered. */
osViSwapBuffer(cfb_16_a);
/*
* Make sure there isn't an old retrace in queue
* (assumes queue has a depth of 1)
*/
if (MQ_IS_FULL(&retraceMessageQ))
(void)osRecvMesg(&retraceMessageQ, NULL, OS_MESG_BLOCK);
/* Wait for Vertical retrace to finish swap buffers */
(void)osRecvMesg(&retraceMessageQ, NULL, OS_MESG_BLOCK);
switch (soundEffect) {
case SOUND_PASS:
chkPlaySound(SOUND_PASS);
break;
case SOUND_FAIL:
chkPlaySound(SOUND_FAIL);
break;
case SOUND_NONE:
default:
break;
}
/*
* Now wait for number of retrace intervals specified by delay
*/
for (i = 0; i < delay; i++) {
(void)osRecvMesg(&retraceMessageQ, NULL, OS_MESG_BLOCK);
}
/*
* If a test failed, set a global variable to indicate this
* (so that we'll not print "PASS" at the end of the test sequence),
* then stall & wait for the user to press the yellow button.
*/
if ( (flags & GNG_PASS_FAIL_BIT) && (testStatus != 0) ) {
pstatus->testFailed = 1;
ZaruWaitForNextTestButton();
}
}