testDriver.c
7.24 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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Ported from Nintendo ZARU GNG Test
:set tabstop=4
Changed: Delete all zaru related code
To add the new test:
Add the routine(return #of errors) in testlist.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <ultra64.h>
#include "testDriver.h"
#include "gng.h"
extern void ssn(void);
extern int controllerSlot;
Test_t testList[] = {
{ 0, &(ContTest_bb) ,"Controller test" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexCONT },
{ 0, &(rsp) ,"RSP Diagnostic Tests" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexRSP },
{ 0, &(dlDriver) ,"RDP Display List Checksum" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexRDP },
{ 0, &(WaveOutput) ,"Wave Output" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexWAVE },
{ 1, &(music44100) ,"Music with 44100Hz" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,Index441 },
{ 1, &(music32000) ,"Music with 32000Hz" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,Index320 },
{ 1, &(music22050) ,"Music with 22050Hz" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,Index220 },
{ 1, &(RunViTests) ,"Video Patterns" ,GNG_PASS_FAIL_BIT, PASS_MESSAGE_RETRACE_COUNT,IndexVIDEO },
};
int WaveOutput()
{
char message[256];
int length;
length=SNDLENGTHDEFAULT;
sprintf(message,"When press start,\nOutput sin wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
while (!GetTrigger());
audioTest(ZARU_SINWAVE,length);
sprintf(message,"When press start,\nOutput saw wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
while (!GetTrigger());
audioTest(ZARU_SAWWAVE,length);
sprintf(message,"When press start,\nOutput triangle wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
while (!GetTrigger());
audioTest(ZARU_TRIWAVE,length);
sprintf(message,"When press start,\nOutput rectangle wave\n");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
while (!GetTrigger());
audioTest(ZARU_RCTWAVE,length);
sprintf(message,"When press start,\nOutput sin wave\nonly Left channel");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
while (!GetTrigger());
audioTest(ZARU_ONLYL,length);
sprintf(message,"When press start,\nOutput sin wave\nonly Right channel");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
while (!GetTrigger());
audioTest(ZARU_ONLYR,length);
return GNG_TEST_SUCCESS;
}
void presstonext()
{
char message[80];
sprintf(message,"When press yellow button,\nGo next test.");
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
}
int my_strcat(char *dst, const char *append)
{
char *stmp = dst, *sadd=(char *) append;
while (*stmp) stmp++;
while (*sadd)
*stmp++ = *sadd++;
*stmp = '\0';
return 0;
}
/* Controller test for BB player */
int ContTest_bb()
{
int wait_to_start = 1, press_A_num=0, A_pressed=0;
int buf_change=1, i;
char pattern, msg[1024], sxy[64];
OSContStatus sdata[MAXCONTROLLERS];
OSContPad ctrl_data[MAXCONTROLLERS];
u16 but, old_but[MAXCONTROLLERS], key;
s8 stickX, old_stickX[MAXCONTROLLERS],
stickY, old_stickY[MAXCONTROLLERS];
/* assume siMessageQ are already created in mainproc() */
osSetEventMesg(OS_EVENT_SI, &siMessageQ, (OSMesg)NULL);
osContInit(&siMessageQ, &pattern, &sdata[0]);
while (press_A_num < 3) {
if (wait_to_start) {
sprintf(msg,"BB Controller test\n\n\n\nPress start ...\n");
if (buf_change) {
gng_report(msg,1,GNG_INHIBIT_PRINT,1);
buf_change = 0;
}
} else
sprintf(msg, "BB Controller test\n");
osContStartReadData(&siMessageQ);
osRecvMesg(&siMessageQ, NULL, OS_MESG_BLOCK);
osContGetReadData(ctrl_data);
for (i=key=buf_change=0; i<MAXCONTROLLERS; i++) {
but = ctrl_data[i].button;
stickX = ctrl_data[i].stick_x & 0xff;
stickY = ctrl_data[i].stick_y & 0xff;
key |= but;
buf_change |= (but != old_but[i]) || (old_stickY[i] != stickY) || (old_stickX[i] != stickX);
}
if (wait_to_start) {
if (key & CONT_START) {
wait_to_start = 0;
buf_change = 1;
for (i=0; i<MAXCONTROLLERS; i++) {
old_but[i] = but;
old_stickX[i] = stickX;
old_stickY[i] = stickY;
}
}
continue;
}
if ( (A_pressed) && !(key & CONT_A) )
press_A_num++;
A_pressed = key & CONT_A;
for (i=0; i<MAXCONTROLLERS; i++) {
but = ctrl_data[i].button;
stickX = ctrl_data[i].stick_x & 0xff;
stickY = ctrl_data[i].stick_y & 0xff;
if ( ctrl_data[i].errno != CONT_NO_RESPONSE_ERROR ) {
if (i==0) my_strcat(msg, "LC: ");
else {
sprintf(sxy, "J%d:", i);
my_strcat(msg, sxy);
}
if (but & CONT_START) my_strcat(msg, " Start");
if (but & CONT_A) my_strcat(msg, " A");
if (but & CONT_B) my_strcat(msg, " B");
if (but & CONT_G) my_strcat(msg, " G");
if (but & CONT_L) my_strcat(msg, " L");
if (but & CONT_R) my_strcat(msg, " R");
if (but & CONT_E) my_strcat(msg, " E");
if (but & CONT_C) my_strcat(msg, " C");
if (but & CONT_F) my_strcat(msg, " F");
if (but & CONT_D) my_strcat(msg, " D");
if (but & CONT_UP) my_strcat(msg, " Up");
if (but & CONT_DOWN) my_strcat(msg, " Down");
if (but & CONT_LEFT) my_strcat(msg, " Left");
if (but & CONT_RIGHT) my_strcat(msg, " Right");
if (but) my_strcat(msg, " pressed");
sprintf(sxy, "\n x=%d, y=%d\n", stickX, stickY);
my_strcat(msg, sxy);
}
old_but[i] = but;
old_stickX[i] = stickX;
old_stickY[i] = stickY;
}
my_strcat(msg, "\n\nPress A 3 times to quit");
if (buf_change) {
gng_report(msg,1,GNG_INHIBIT_PRINT,1);
buf_change = 0;
}
}
return GNG_TEST_SUCCESS;
}
void testDriver()
{
int i;
int errCount=0, total;
char message[256];
total = sizeof(testList)/sizeof(Test_t);
#if CONTROLLER_TEST_ONLY
ContTest_bb();
#else
for (i=0; i<total; i++) {
errCount += testList[i].pTestFunction();
}
sprintf(message,"GNG Test Report \n Total number=%d \nFailed case=%d",
total, errCount);
gng_report(message, 1, GNG_INHIBIT_PRINT, 1);
#endif
return;
}