uc_assert.c
6.83 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
/*---------------------------------------------------------------------
Copyright (C) 1997, Nintendo.
File uc_assert.c
Coded by Yoshitaka Yasumoto. Feb 19, 1997.
Modified by
Comments
$Id: uc_assert.c,v 1.1.1.1 2002/05/02 03:27:17 blythe Exp $
---------------------------------------------------------------------*/
#include <ultra64.h>
/*==========================================================================*
* ucode のアサートの判定
*==========================================================================*/
u32 ucCheckAssert(void)
{
/*
* S2DEX ucode が異常終了したときは SP_STATUS_SIG7 が立つ
*/
return (IO_READ(SP_STATUS_REG) & SP_STATUS_SIG7);
}
/*==========================================================================*
* ucode デコード用テーブル
*==========================================================================*/
static char *decode_table[] = {
"Undefined", "G_SWITCH_UCODE",
0, "G_OBJ_RENDERMODE", "G_OBJ_RECTANGLE_R", "G_TEXRECT_DONE",
"G_RDPHALF_1", 0, 0, 0,
"G_ENDDL", "G_SETOTHERMODE_L", "G_SETOTHERMODE_H", 0,
"G_MOVEWORD", "G_SPRITE2D_DRAW", "G_SPRITE2D_SCALEFLIP", 0,
"G_NOOP", "G_OBJ_LOADTMEM", "G_OBJ_LDTM_SPRITE", "G_OBJ_LDTM_RECT",
"G_OBJ_LDTM_RECT_R",0,0,0,
0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0,
"G_TEXRECT", "G_TEXRECTFLIP", "G_RDPLOADSYNC", "G_RDPPIPESYNC",
"G_RDPTILESYNC", "G_RDPFULLSYNC", "G_SETKEYGB", "G_SETKEYR",
"G_SETCONVERT", "G_SETSCISSOR", "G_SETPRIMDEPTH", "G_RDPSETOTHERMODE",
"G_LOADTLUT", 0, "G_SETTILESIZE", "G_LOADBLOCK",
"G_LOADTILE", "G_SETTILE", "G_FILLRECT", "G_SETFILLCOLOR",
"G_SETFOGCOLOR", "G_SETBLENDCOLOR", "G_SETPRIMCOLOR", "G_SETENVCOLOR",
"G_SETCOMBINE", "G_SETTIMG", "G_SETZIMG", "G_SETCIMG",
"G_NOP", "G_BG_RECT1CYC", "G_BG_RECTCOPY","G_OBJ_RECTANGLE",
"G_OBJ_SPRITE", "G_OBJ_MOVEMEM", "G_DL"
};
/*==========================================================================*
* DL ログ出力
* RSP が処理したコマンドのログを出力する
*==========================================================================*/
void ucDebugGfxLogPrint(OSTask *tp)
{
int n, gfx, cmd;
u32 logtop = (u32)(tp->t.data_size);
u32 logend;
if (NULL == logtop) return;
osSyncPrintf("----------------------------------------RSP DL Log\n");
/*------ この位置に現在のログの出力位置が格納されている ------*/
logend = IO_READ(SP_DMEM_START+0xff4);
/*------ ログを順にデコードしていく ------*/
for (n = logtop; n < logend; n += 8){
gfx = IO_READ(n+4);
cmd = (u8)(((u8)(gfx>>24)) - (u8)0xaf) + 1;
if (cmd < 1 || 0x106-0xaf+1 < cmd) cmd = 0;
if (decode_table[cmd] == 0) cmd = 0;
osSyncPrintf("%08x: %08x %s\n", IO_READ(n), gfx, decode_table[cmd]);
}
return;
}
/*==========================================================================*
* RDP コマンド出力
*==========================================================================*/
static char *decode_rdp[] = {
"Noop", "Undefined", 0, 0,
0, 0, 0, 0,
"Tri", "ZB-Tri", "TX-Tri", "TX-ZB-Tri",
"Shade-Tri", "Shade-ZB-Tri", "Shade-TX-Tri", "Shade-TX-ZB-Tri",
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
"G_TEXRECT", "G_TEXRECTFLIP", "G_RDPLOADSYNC", "G_RDPPIPESYNC",
"G_RDPTILESYNC", "G_RDPFULLSYNC", "G_SETKEYGB", "G_SETKEYR",
"G_SETCONVERT", "G_SETSCISSOR", "G_SETPRIMDEPTH", "G_RDPSETOTHERMODE",
"G_LOADTLUT", 0, "G_SETTILESIZE", "G_LOADBLOCK",
"G_LOADTILE", "G_SETTILE", "G_FILLRECT", "G_SETFILLCOLOR",
"G_SETFOGCOLOR", "G_SETBLENDCOLOR", "G_SETPRIMCOLOR", "G_SETENVCOLOR",
"G_SETCOMBINE", "G_SETTIMG", "G_SETZIMG", "G_SETCIMG",
};
static int count_rdp[] = {
32, 32+16, 32+64, 32+64+16, 32+64, 32+64+16, 32+64+64, 32+64+64+16
};
void ucDebugRdpFifoPrint(OSTask *tp)
{
u8 head;
u32 n, cmd0, cmd1;
u32 fifotop = (u32)(tp->t.output_buff);
u32 fifoend = (u32)(tp->t.output_buff_size);
int count = 0;
osSyncPrintf("---------------------------------------- RDP FIFO\n");
for (n = fifotop; n < fifoend; n += 8){
cmd0 = IO_READ(n+0);
cmd1 = IO_READ(n+4);
if (count > 0){
count -= 8;
} else {
head = (cmd0 >> 24) & 0x3f;
if (decode_rdp[head] == 0) head = 1; /* Undefined */
if (8 <= head && head <= 15){ /* Triangle コマンド */
count = count_rdp[head-8] - 8;
} else if (head == 0x24 || head == 0x25){ /* TextureRectangle コマンド */
count = 8;
}
}
osSyncPrintf("%08x: %08x %08x %s\n", n, cmd0, cmd1, decode_rdp[head]);
if (head == 0x29) break;
}
}
/*==========================================================================*
* Debug 用エリア出力
*==========================================================================*/
void ucDebugInfoPrint(void)
{
osSyncPrintf("Debug = (%08x %08x %08x %08x %08x)\n",
IO_READ(SP_DMEM_START+0xfac), IO_READ(SP_DMEM_START+0xfb0),
IO_READ(SP_DMEM_START+0xfb4), IO_READ(SP_DMEM_START+0xfb8),
IO_READ(SP_DMEM_START+0xfbc));
}
/*==========================================================================*
* Assert 情報データ出力
*==========================================================================*/
void ucDebugAssertPrint(void)
{
osSyncPrintf("-------- Assert!! --------\nPC=%08x inp=%08x gfx0=0x%08x\n",
IO_READ(SP_DMEM_START+0xfa8), IO_READ(SP_DMEM_START+0xfa0),
IO_READ(SP_DMEM_START+0xfa4));
}
/*==========================================================================*
* IMEM 出力
*==========================================================================*/
void ucDebugIMEMPrint(void)
{
u32 i;
u32 p0, p1, p2, p3;
osSyncPrintf("----------------------------------------IMEM\n");
for (i = 0; i < 1024; i += 4){
p0 = IO_READ(SP_IMEM_START+(i+0)*4);
p1 = IO_READ(SP_IMEM_START+(i+1)*4);
p2 = IO_READ(SP_IMEM_START+(i+2)*4);
p3 = IO_READ(SP_IMEM_START+(i+3)*4);
osSyncPrintf("%04x : %08x %08x %08x %08x\n", i*4, p0, p1, p2, p3);
}
}
/*==========================================================================*
* DMEM 出力
*==========================================================================*/
void ucDebugDMEMPrint(void)
{
u32 i;
u32 p0, p1, p2, p3;
osSyncPrintf("----------------------------------------DMEM\n");
for (i = 0; i < 1024; i += 4){
p0 = IO_READ(SP_DMEM_START+(i+0)*4);
p1 = IO_READ(SP_DMEM_START+(i+1)*4);
p2 = IO_READ(SP_DMEM_START+(i+2)*4);
p3 = IO_READ(SP_DMEM_START+(i+3)*4);
osSyncPrintf("%04x : %08x %08x %08x %08x\n", i*4, p0, p1, p2, p3);
}
}
/*======== End of uc_assert.c ========*/