Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/mupen64plus-video-glide64/src/Debugger.cpp
2 views
1
/*
2
* Glide64 - Glide video plugin for Nintendo 64 emulators.
3
* Copyright (c) 2002 Dave2001
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public
16
* Licence along with this program; if not, write to the Free
17
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA
19
*/
20
21
//****************************************************************
22
//
23
// Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
24
// Project started on December 29th, 2001
25
//
26
// To modify Glide64:
27
// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
28
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
29
//
30
// Official Glide64 development channel: #Glide64 on EFnet
31
//
32
// Original author: Dave2001 ([email protected])
33
// Other authors: Gonetz, Gugaman
34
//
35
//****************************************************************
36
37
#define M64P_PLUGIN_PROTOTYPES 1
38
#include "m64p_types.h"
39
#include "m64p_plugin.h"
40
#include "m64p_config.h"
41
#include "m64p_vidext.h"
42
#include "Util.h"
43
#include "Debugger.h"
44
#include <stdio.h>
45
#include "Gfx1.3.h"
46
#ifndef _WIN32
47
#include <stdarg.h>
48
#include <string.h>
49
#endif // _WIN32
50
51
DEBUGGER debug;
52
53
const char *FBLa[] = { "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" };
54
const char *FBLb[] = { "G_BL_A_IN", "G_BL_A_FOG", "G_BL_A_SHADE", "G_BL_0" };
55
const char *FBLc[] = { "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG"};
56
const char *FBLd[] = { "G_BL_1MA", "G_BL_A_MEM", "G_BL_1", "G_BL_0" };
57
const char *str_lod[] = { "1", "2", "4", "8", "16", "32", "64", "128", "256" };
58
const char *str_aspect[] = { "1x8", "1x4", "1x2", "1x1", "2x1", "4x1", "8x1" };
59
60
#define SX(x) ((x)*rdp.scale_1024)
61
#define SY(x) ((x)*rdp.scale_768)
62
63
#ifdef COLORED_DEBUGGER
64
#define COL_CATEGORY() grConstantColorValue(0xD288F400)
65
#define COL_UCC() grConstantColorValue(0xFF000000)
66
#define COL_CC() grConstantColorValue(0x88C3F400)
67
#define COL_UAC() grConstantColorValue(0xFF808000)
68
#define COL_AC() grConstantColorValue(0x3CEE5E00)
69
#define COL_TEXT() grConstantColorValue(0xFFFFFF00)
70
#define COL_SEL(x) grConstantColorValue((x)?0x00FF00FF:0x800000FF)
71
#else
72
#define COL_CATEGORY()
73
#define COL_UCC()
74
#define COL_CC()
75
#define COL_UAC()
76
#define COL_AC()
77
#define COL_TEXT()
78
#define COL_SEL(x)
79
#endif
80
81
#define COL_GRID 0xFFFFFF80
82
83
BOOL grid = 0;
84
85
//
86
// debug_init - initialize the debugger
87
//
88
89
void debug_init ()
90
{
91
debug.capture = 0;
92
debug.selected = SELECTED_TRI;
93
debug.screen = NULL;
94
debug.tri_list = NULL;
95
debug.tri_last = NULL;
96
debug.tri_sel = NULL;
97
debug.tmu = 0;
98
99
debug.tex_scroll = 0;
100
debug.tex_sel = 0;
101
102
debug.draw_mode = 0;
103
}
104
105
//
106
// debug_cacheviewer - views the debugger's cache
107
//
108
109
void debug_cacheviewer ()
110
{
111
grCullMode (GR_CULL_DISABLE);
112
113
int i;
114
for (i=0; i<2; i++)
115
{
116
grTexFilterMode (i,
117
(settings.filter_cache)?GR_TEXTUREFILTER_BILINEAR:GR_TEXTUREFILTER_POINT_SAMPLED,
118
(settings.filter_cache)?GR_TEXTUREFILTER_BILINEAR:GR_TEXTUREFILTER_POINT_SAMPLED);
119
grTexClampMode (i,
120
GR_TEXTURECLAMP_CLAMP,
121
GR_TEXTURECLAMP_CLAMP);
122
}
123
124
switch (debug.draw_mode)
125
{
126
case 0:
127
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
128
GR_COMBINE_FACTOR_ONE,
129
GR_COMBINE_LOCAL_NONE,
130
GR_COMBINE_OTHER_TEXTURE,
131
FXFALSE);
132
grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
133
GR_COMBINE_FACTOR_ONE,
134
GR_COMBINE_LOCAL_NONE,
135
GR_COMBINE_OTHER_TEXTURE,
136
FXFALSE);
137
break;
138
case 1:
139
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
140
GR_COMBINE_FACTOR_ONE,
141
GR_COMBINE_LOCAL_NONE,
142
GR_COMBINE_OTHER_TEXTURE,
143
FXFALSE);
144
grAlphaCombine (GR_COMBINE_FUNCTION_LOCAL,
145
GR_COMBINE_FACTOR_NONE,
146
GR_COMBINE_LOCAL_CONSTANT,
147
GR_COMBINE_OTHER_NONE,
148
FXFALSE);
149
grConstantColorValue (0xFFFFFFFF);
150
break;
151
case 2:
152
grColorCombine (GR_COMBINE_FUNCTION_LOCAL,
153
GR_COMBINE_FACTOR_NONE,
154
GR_COMBINE_LOCAL_CONSTANT,
155
GR_COMBINE_OTHER_NONE,
156
FXFALSE);
157
grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
158
GR_COMBINE_FACTOR_ONE,
159
GR_COMBINE_LOCAL_NONE,
160
GR_COMBINE_OTHER_TEXTURE,
161
FXFALSE);
162
grConstantColorValue (0xFFFFFFFF);
163
}
164
165
if (debug.tmu == 1)
166
{
167
grTexCombine (GR_TMU1,
168
GR_COMBINE_FUNCTION_LOCAL,
169
GR_COMBINE_FACTOR_NONE,
170
GR_COMBINE_FUNCTION_LOCAL,
171
GR_COMBINE_FACTOR_NONE,
172
FXFALSE,
173
FXFALSE);
174
175
grTexCombine (GR_TMU0,
176
GR_COMBINE_FUNCTION_SCALE_OTHER,
177
GR_COMBINE_FACTOR_ONE,
178
GR_COMBINE_FUNCTION_SCALE_OTHER,
179
GR_COMBINE_FACTOR_ONE,
180
FXFALSE,
181
FXFALSE);
182
}
183
else
184
{
185
grTexCombine (GR_TMU0,
186
GR_COMBINE_FUNCTION_LOCAL,
187
GR_COMBINE_FACTOR_NONE,
188
GR_COMBINE_FUNCTION_LOCAL,
189
GR_COMBINE_FACTOR_NONE,
190
FXFALSE,
191
FXFALSE);
192
}
193
194
grAlphaBlendFunction (GR_BLEND_SRC_ALPHA,
195
GR_BLEND_ONE_MINUS_SRC_ALPHA,
196
GR_BLEND_ONE,
197
GR_BLEND_ZERO);
198
199
// Draw texture memory
200
for (i=0; i<4; i++)
201
{
202
for (DWORD x=0; x<16; x++)
203
{
204
DWORD y = i+debug.tex_scroll;
205
if (x+y*16 >= (DWORD)rdp.n_cached[debug.tmu]) break;
206
207
VERTEX v[4] = {
208
{ SX(x*64.0f), SY(512+64.0f*i), 1, 1, 0, 0, 0, 0, {0, 0, 0, 0} },
209
{ SX(x*64.0f+64.0f*rdp.cache[debug.tmu][x+y*16].scale_x), SY(512+64.0f*i), 1, 1, 255*rdp.cache[debug.tmu][x+y*16].scale_x, 0, 0, 0, {0, 0, 0, 0} },
210
{ SX(x*64.0f), SY(512+64.0f*i+64.0f*rdp.cache[debug.tmu][x+y*16].scale_y), 1, 1, 0, 255*rdp.cache[debug.tmu][x+y*16].scale_y, 0, 0, {0, 0, 0, 0} },
211
{ SX(x*64.0f+64.0f*rdp.cache[debug.tmu][x+y*16].scale_x), SY(512+64.0f*i+64.0f*rdp.cache[debug.tmu][x+y*16].scale_y), 1, 1, 255*rdp.cache[debug.tmu][x+y*16].scale_x, 255*rdp.cache[debug.tmu][x+y*16].scale_y, 0, 0, {0, 0, 0, 0} } };
212
for (int i=0; i<4; i++)
213
{
214
v[i].u1 = v[i].u0;
215
v[i].v1 = v[i].v0;
216
}
217
218
ConvertCoordsConvert (v, 4);
219
220
grTexSource(debug.tmu,
221
grTexMinAddress(debug.tmu) + rdp.cache[debug.tmu][x+y*16].tmem_addr,
222
GR_MIPMAPLEVELMASK_BOTH,
223
&rdp.cache[debug.tmu][x+y*16].t_info);
224
225
grDrawTriangle (&v[2], &v[1], &v[0]);
226
grDrawTriangle (&v[2], &v[3], &v[1]);
227
}
228
}
229
230
/* for (i=0; i<4; i++)
231
{
232
for (DWORD x=0; x<16; x++)
233
{
234
DWORD y = i+debug.tex_scroll;
235
if (x+y*16 >= (DWORD)rdp.n_cached[debug.tmu]) break;
236
237
VERTEX v[4] = {
238
{ SX(x*64.0f), SY(768-64.0f*i), 1, 1, 0, 0, 0, 0, 0, 0, 0 },
239
{ SX(x*64.0f+64.0f), SY(768-64.0f*i), 1, 1, 255, 0, 0, 0, 0, 0, 0 },
240
{ SX(x*64.0f), SY(768-64.0f*i-64.0f), 1, 1, 0, 255, 0, 0, 0, 0, 0 },
241
{ SX(x*64.0f+64.0f), SY(768-64.0f*i-64.0f), 1, 1, 255, 255, 0, 0, 0, 0, 0 } };
242
for (int i=0; i<4; i++)
243
{
244
v[i].u1 = v[i].u0;
245
v[i].v1 = v[i].v0;
246
}
247
248
ConvertCoordsConvert (v, 4);
249
250
grTexSource(debug.tmu,
251
grTexMinAddress(debug.tmu) + rdp.cache[debug.tmu][x+y*16].tmem_addr,
252
GR_MIPMAPLEVELMASK_BOTH,
253
&rdp.cache[debug.tmu][x+y*16].t_info);
254
255
grDrawTriangle (&v[2], &v[1], &v[0]);
256
grDrawTriangle (&v[2], &v[3], &v[1]);
257
}
258
}*/
259
}
260
261
//
262
// debug_capture - does a frame capture event (for debugging)
263
//
264
#ifdef _WIN32
265
void debug_capture ()
266
{
267
DWORD i,j;
268
269
if (debug.tri_list == NULL) goto END;
270
debug.tri_sel = debug.tri_list;
271
debug.selected = SELECTED_TRI;
272
273
// Connect the list
274
debug.tri_last->pNext = debug.tri_list;
275
276
while (!(GetAsyncKeyState(VK_INSERT) & 0x0001))
277
{
278
// Check for clicks
279
if (GetAsyncKeyState(GetSystemMetrics(SM_SWAPBUTTON)?VK_RBUTTON:VK_LBUTTON) & 0x0001)
280
{
281
POINT pt;
282
GetCursorPos (&pt);
283
284
//int diff = settings.scr_res_y-settings.res_y;
285
286
if (pt.y <= (int)settings.res_y)
287
{
288
int x = pt.x;
289
int y = pt.y;//settings.res_y - (pt.y - diff);
290
291
TRI_INFO *start;
292
TRI_INFO *tri;
293
if (debug.tri_sel == NULL) tri = debug.tri_list, start = debug.tri_list;
294
else tri = debug.tri_sel->pNext, start = debug.tri_sel;
295
296
// Select a triangle (start from the currently selected one)
297
do {
298
if (tri->v[0].x == tri->v[1].x &&
299
tri->v[0].y == tri->v[1].y)
300
{
301
tri = tri->pNext;
302
continue;
303
}
304
305
for (i=0; i<tri->nv; i++)
306
{
307
j=i+1;
308
if (j==tri->nv) j=0;
309
310
if ((y-tri->v[i].y)*(tri->v[j].x-tri->v[i].x) -
311
(x-tri->v[i].x)*(tri->v[j].y-tri->v[i].y) < 0)
312
break; // It's outside
313
}
314
315
if (i==tri->nv) // all lines passed
316
{
317
debug.tri_sel = tri;
318
break;
319
}
320
321
for (i=0; i<tri->nv; i++)
322
{
323
j=i+1;
324
if (j==tri->nv) j=0;
325
326
if ((y-tri->v[i].y)*(tri->v[j].x-tri->v[i].x) -
327
(x-tri->v[i].x)*(tri->v[j].y-tri->v[i].y) > 0)
328
break; // It's outside
329
}
330
331
if (i==tri->nv) // all lines passed
332
{
333
debug.tri_sel = tri;
334
break;
335
}
336
337
tri = tri->pNext;
338
} while (tri != start);
339
}
340
else
341
{
342
// on a texture
343
debug.tex_sel = (((DWORD)((pt.y-SY(512))/SY(64))+debug.tex_scroll)*16) +
344
(DWORD)(pt.x/SX(64));
345
}
346
}
347
348
debug_keys ();
349
350
grBufferClear (0, 0, 0xFFFF);
351
352
// Copy the screen capture back to the screen:
353
// Lock the backbuffer
354
GrLfbInfo_t info;
355
while (!grLfbLock (GR_LFB_WRITE_ONLY,
356
GR_BUFFER_BACKBUFFER,
357
GR_LFBWRITEMODE_565,
358
GR_ORIGIN_UPPER_LEFT,
359
FXFALSE,
360
&info));
361
362
DWORD offset_src=0/*(settings.scr_res_y-settings.res_y)*info.strideInBytes*/, offset_dst=0;
363
364
// Copy the screen
365
for (DWORD y=0; y<settings.res_y; y++)
366
{
367
memcpy ((BYTE*)info.lfbPtr + offset_src, debug.screen + offset_dst, settings.res_x << 1);
368
offset_dst += settings.res_x << 1;
369
offset_src += info.strideInBytes;
370
}
371
372
// Unlock the backbuffer
373
grLfbUnlock (GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER);
374
375
// Do the cacheviewer
376
debug_cacheviewer ();
377
378
// **
379
// 3/16/02: Moved texture viewer out of loop, remade it. Now it's simpler, and
380
// supports TMU1. [Dave2001]
381
// Original by Gugaman
382
383
if (debug.page == PAGE_TEX_INFO)
384
{
385
grTexSource(debug.tmu,
386
grTexMinAddress(debug.tmu) + rdp.cache[debug.tmu][debug.tex_sel].tmem_addr,
387
GR_MIPMAPLEVELMASK_BOTH,
388
&rdp.cache[debug.tmu][debug.tex_sel].t_info);
389
390
#ifdef SHOW_FULL_TEXVIEWER
391
float scx = 1.0f;
392
float scy = 1.0f;
393
#else
394
float scx = rdp.cache[debug.tmu][debug.tex_sel].scale_x;
395
float scy = rdp.cache[debug.tmu][debug.tex_sel].scale_y;
396
#endif
397
VERTEX v[4] = {
398
{ SX(704.0f), SY(221.0f), 1, 1, 0, 0, 0, 0, 0, 0, 0 },
399
{ SX(704.0f+256.0f*scx), SY(221.0f), 1, 1, 255*scx, 0, 255*scx, 0, 0, 0, 0 },
400
{ SX(704.0f), SY(221.0f+256.0f*scy), 1, 1, 0, 255*scy, 0, 255*scy, 0, 0, 0 },
401
{ SX(704.0f+256.0f*scx), SY(221.0f+256.0f*scy), 1, 1, 255*scx, 255*scy, 255*scx, 255*scy, 0, 0, 0 } };
402
ConvertCoordsConvert (v, 4);
403
VERTEX *varr[4] = { &v[0], &v[1], &v[2], &v[3] };
404
grDrawVertexArray (GR_TRIANGLE_STRIP, 4, varr);
405
}
406
407
// **
408
409
grTexFilterMode (GR_TMU0,
410
GR_TEXTUREFILTER_BILINEAR,
411
GR_TEXTUREFILTER_BILINEAR);
412
413
grColorCombine (GR_COMBINE_FUNCTION_LOCAL,
414
GR_COMBINE_FACTOR_NONE,
415
GR_COMBINE_LOCAL_CONSTANT,
416
GR_COMBINE_OTHER_NONE,
417
FXFALSE);
418
419
grAlphaCombine (GR_COMBINE_FUNCTION_LOCAL,
420
GR_COMBINE_FACTOR_NONE,
421
GR_COMBINE_LOCAL_CONSTANT,
422
GR_COMBINE_OTHER_NONE,
423
FXFALSE);
424
425
grConstantColorValue (0x0000FFFF);
426
427
VERTEX *v[8];
428
if (debug.tri_sel)
429
{
430
// Draw the outline around the selected triangle
431
for (i=0; i<debug.tri_sel->nv; i++)
432
{
433
j=i+1;
434
if (j>=debug.tri_sel->nv) j=0;
435
436
grDrawLine (&debug.tri_sel->v[i], &debug.tri_sel->v[j]);
437
438
v[i] = &debug.tri_sel->v[i];
439
}
440
}
441
442
// and the selected texture
443
DWORD t_y = ((debug.tex_sel & 0xFFFFFFF0) >> 4) - debug.tex_scroll;
444
DWORD t_x = debug.tex_sel & 0xF;
445
VERTEX vt[4] = {
446
{ SX(t_x*64.0f), SY(512+64.0f*t_y), 1, 1 },
447
{ SX(t_x*64.0f+64.0f), SY(512+64.0f*t_y), 1, 1 },
448
{ SX(t_x*64.0f), SY(512+64.0f*t_y+64.0f), 1, 1 },
449
{ SX(t_x*64.0f+64.0f), SY(512+64.0f*t_y+64.0f), 1, 1 } };
450
if (t_y < 4)
451
{
452
grDrawLine (&vt[0], &vt[1]);
453
grDrawLine (&vt[1], &vt[3]);
454
grDrawLine (&vt[3], &vt[2]);
455
grDrawLine (&vt[2], &vt[0]);
456
}
457
458
grConstantColorValue (0xFF000020);
459
460
if (t_y < 4)
461
{
462
grDrawTriangle (&vt[2], &vt[1], &vt[0]);
463
grDrawTriangle (&vt[2], &vt[3], &vt[1]);
464
}
465
466
if (debug.tri_sel)
467
grDrawVertexArray (GR_TRIANGLE_FAN, debug.tri_sel->nv, &v);
468
469
// Draw the outline of the cacheviewer
470
if (debug.page == PAGE_TEX_INFO)
471
{
472
/*grConstantColorValue (0xFF0000FF);
473
float scx = rdp.cache[debug.tmu][debug.tex_sel].scale_x;
474
float scy = rdp.cache[debug.tmu][debug.tex_sel].scale_y;
475
VERTEX v[4] = {
476
{ SX(704.0f), SY(271.0f), 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
477
{ SX(704.0f+256.0f*scx), SY(271.0f), 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
478
{ SX(704.0f), SY(271.0f-256.0f*scy), 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
479
{ SX(704.0f+256.0f*scx), SY(271.0f-256.0f*scy), 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
480
VERTEX *varr[5] = { &v[0], &v[1], &v[3], &v[2], &v[0] };
481
grDrawVertexArray (GR_LINE_STRIP, 5, varr);*/
482
483
float scx = rdp.cache[debug.tmu][debug.tex_sel].scale_x;
484
float scy = rdp.cache[debug.tmu][debug.tex_sel].scale_y;
485
486
// And the grid
487
if (grid)
488
{
489
grConstantColorValue (COL_GRID);
490
491
float scale_y = (256.0f * scy) / (float)rdp.cache[debug.tmu][debug.tex_sel].height;
492
for (int y=0; y<=(int)rdp.cache[debug.tmu][debug.tex_sel].height; y++)
493
{
494
float y_val = SY(221.0f+y*scale_y);
495
VERTEX vh[2] = {
496
{ SX(704.0f), y_val, 1, 1 },
497
{ SX(704.0f+255.0f*scx), y_val, 1, 1 } };
498
grDrawLine (&vh[0], &vh[1]);
499
}
500
501
float scale_x = (256.0f * scx) / (float)rdp.cache[debug.tmu][debug.tex_sel].width;
502
for (int x=0; x<=(int)rdp.cache[debug.tmu][debug.tex_sel].width; x++)
503
{
504
float x_val = SX(704.0f+x*scale_x);
505
VERTEX vv[2] = {
506
{ x_val, SX(221.0f), 1, 1 },
507
{ x_val, SX(221.0f+256.0f*scy), 1, 1 } };
508
grDrawLine (&vv[0], &vv[1]);
509
}
510
}
511
}
512
513
grTexCombine (GR_TMU0,
514
GR_COMBINE_FUNCTION_LOCAL,
515
GR_COMBINE_FACTOR_NONE,
516
GR_COMBINE_FUNCTION_LOCAL,
517
GR_COMBINE_FACTOR_NONE,
518
FXFALSE,
519
FXFALSE);
520
521
grColorCombine (GR_COMBINE_FUNCTION_LOCAL,
522
GR_COMBINE_FACTOR_NONE,
523
GR_COMBINE_LOCAL_CONSTANT,
524
GR_COMBINE_OTHER_NONE,
525
FXFALSE);
526
527
grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
528
GR_COMBINE_FACTOR_ONE,
529
GR_COMBINE_LOCAL_NONE,
530
GR_COMBINE_OTHER_TEXTURE,
531
FXFALSE);
532
533
grConstantColorValue (0xFFFFFF00);
534
535
// Output the information about the selected triangle
536
grTexSource(GR_TMU0, // Text
537
grTexMinAddress(debug.tmu)+ offset_font,
538
GR_MIPMAPLEVELMASK_BOTH,
539
&fontTex);
540
541
static char *cycle_mode_s[4] = { "1 cycle (0)", "2 cycle (1)", "copy (2)", "fill (3)" };
542
543
#define OUTPUT(fmt,other) output(642,(float)i,1,fmt,other); i-=16;
544
#define OUTPUT1(fmt,other,other1) output(642,(float)i,1,fmt,other,other1); i-=16;
545
#define OUTPUT_(fmt,cc) COL_SEL(cc); x=642; output(x,(float)i,1,fmt,0); x+=8*(strlen(fmt)+1)
546
#define _OUTPUT(fmt,cc) COL_SEL(cc); output(x,(float)i,1,fmt,0); x+=8*(strlen(fmt)+1)
547
i = 740;
548
float x;
549
if (debug.page == PAGE_GENERAL && debug.tri_sel)
550
{
551
COL_CATEGORY();
552
OUTPUT ("GENERAL (page 1):",0);
553
COL_TEXT();
554
OUTPUT ("tri #%d", debug.tri_sel->tri_n);
555
OUTPUT ("type: %s", tri_type[debug.tri_sel->type]);
556
OUTPUT ("geom: 0x%08lx", debug.tri_sel->geom_mode);
557
OUTPUT ("othermode_h: 0x%08lx", debug.tri_sel->othermode_h);
558
OUTPUT ("othermode_l: 0x%08lx", debug.tri_sel->othermode_l);
559
OUTPUT ("flags: 0x%08lx", debug.tri_sel->flags);
560
OUTPUT ("",0);
561
COL_CATEGORY();
562
OUTPUT ("COMBINE:",0);
563
COL_TEXT();
564
OUTPUT ("cycle_mode: %s", cycle_mode_s[debug.tri_sel->cycle_mode]);
565
OUTPUT ("cycle1: 0x%08lx", debug.tri_sel->cycle1);
566
OUTPUT ("cycle2: 0x%08lx", debug.tri_sel->cycle2);
567
if (debug.tri_sel->uncombined & 1)
568
COL_UCC();
569
else
570
COL_CC();
571
OUTPUT ("a0: %s", Mode0[(debug.tri_sel->cycle1)&0x0000000F]);
572
OUTPUT ("b0: %s", Mode1[(debug.tri_sel->cycle1>>4)&0x0000000F]);
573
OUTPUT ("c0: %s", Mode2[(debug.tri_sel->cycle1>>8)&0x0000001F]);
574
OUTPUT ("d0: %s", Mode3[(debug.tri_sel->cycle1>>13)&0x00000007]);
575
if (debug.tri_sel->uncombined & 2)
576
COL_UAC();
577
else
578
COL_AC();
579
OUTPUT ("Aa0: %s", Alpha0[(debug.tri_sel->cycle1>>16)&0x00000007]);
580
OUTPUT ("Ab0: %s", Alpha1[(debug.tri_sel->cycle1>>19)&0x00000007]);
581
OUTPUT ("Ac0: %s", Alpha2[(debug.tri_sel->cycle1>>22)&0x00000007]);
582
OUTPUT ("Ad0: %s", Alpha3[(debug.tri_sel->cycle1>>25)&0x00000007]);
583
if (debug.tri_sel->uncombined & 1)
584
COL_UCC();
585
else
586
COL_CC();
587
OUTPUT ("a1: %s", Mode0[(debug.tri_sel->cycle2)&0x0000000F]);
588
OUTPUT ("b1: %s", Mode1[(debug.tri_sel->cycle2>>4)&0x0000000F]);
589
OUTPUT ("c1: %s", Mode2[(debug.tri_sel->cycle2>>8)&0x0000001F]);
590
OUTPUT ("d1: %s", Mode3[(debug.tri_sel->cycle2>>13)&0x00000007]);
591
if (debug.tri_sel->uncombined & 2)
592
COL_UAC();
593
else
594
COL_AC();
595
OUTPUT ("Aa1: %s", Alpha0[(debug.tri_sel->cycle2>>16)&0x00000007]);
596
OUTPUT ("Ab1: %s", Alpha1[(debug.tri_sel->cycle2>>19)&0x00000007]);
597
OUTPUT ("Ac1: %s", Alpha2[(debug.tri_sel->cycle2>>22)&0x00000007]);
598
OUTPUT ("Ad1: %s", Alpha3[(debug.tri_sel->cycle2>>25)&0x00000007]);
599
}
600
if ((debug.page == PAGE_TEX1 || debug.page == PAGE_TEX2) && debug.tri_sel)
601
{
602
COL_CATEGORY ();
603
OUTPUT1 ("TEXTURE %d (page %d):", debug.page-PAGE_TEX1, 2+debug.page-PAGE_TEX1);
604
COL_TEXT();
605
int tmu = debug.page - PAGE_TEX1;
606
OUTPUT1 ("cur cache: %d,%d", debug.tri_sel->t[tmu].cur_cache[tmu]&0x0F, debug.tri_sel->t[tmu].cur_cache[tmu]>>4);
607
OUTPUT ("tex_size: %d", debug.tri_sel->t[tmu].size);
608
OUTPUT ("tex_format: %d", debug.tri_sel->t[tmu].format);
609
OUTPUT ("width: %d", debug.tri_sel->t[tmu].width);
610
OUTPUT ("height: %d", debug.tri_sel->t[tmu].height);
611
OUTPUT ("palette: %d", debug.tri_sel->t[tmu].palette);
612
OUTPUT ("clamp_s: %d", debug.tri_sel->t[tmu].clamp_s);
613
OUTPUT ("clamp_t: %d", debug.tri_sel->t[tmu].clamp_t);
614
OUTPUT ("mirror_s: %d", debug.tri_sel->t[tmu].mirror_s);
615
OUTPUT ("mirror_t: %d", debug.tri_sel->t[tmu].mirror_t);
616
OUTPUT ("mask_s: %d", debug.tri_sel->t[tmu].mask_s);
617
OUTPUT ("mask_t: %d", debug.tri_sel->t[tmu].mask_t);
618
OUTPUT ("shift_s: %d", debug.tri_sel->t[tmu].shift_s);
619
OUTPUT ("shift_t: %d", debug.tri_sel->t[tmu].shift_t);
620
OUTPUT ("ul_s: %d", debug.tri_sel->t[tmu].ul_s);
621
OUTPUT ("ul_t: %d", debug.tri_sel->t[tmu].ul_t);
622
OUTPUT ("lr_s: %d", debug.tri_sel->t[tmu].lr_s);
623
OUTPUT ("lr_t: %d", debug.tri_sel->t[tmu].lr_t);
624
OUTPUT ("t_ul_s: %d", debug.tri_sel->t[tmu].t_ul_s);
625
OUTPUT ("t_ul_t: %d", debug.tri_sel->t[tmu].t_ul_t);
626
OUTPUT ("t_lr_s: %d", debug.tri_sel->t[tmu].t_lr_s);
627
OUTPUT ("t_lr_t: %d", debug.tri_sel->t[tmu].t_lr_t);
628
OUTPUT ("scale_s: %f", debug.tri_sel->t[tmu].scale_s);
629
OUTPUT ("scale_t: %f", debug.tri_sel->t[tmu].scale_t);
630
OUTPUT ("s_mode: %s", str_cm[((debug.tri_sel->t[tmu].clamp_s << 1) | debug.tri_sel->t[tmu].mirror_s)&3]);
631
OUTPUT ("t_mode: %s", str_cm[((debug.tri_sel->t[tmu].clamp_t << 1) | debug.tri_sel->t[tmu].mirror_t)&3]);
632
}
633
if (debug.page == PAGE_COLORS && debug.tri_sel)
634
{
635
COL_CATEGORY();
636
OUTPUT ("COLORS (page 4)", 0);
637
COL_TEXT();
638
OUTPUT ("fill: %08lx", debug.tri_sel->fill_color);
639
OUTPUT ("prim: %08lx", debug.tri_sel->prim_color);
640
OUTPUT ("blend: %08lx", debug.tri_sel->blend_color);
641
OUTPUT ("env: %08lx", debug.tri_sel->env_color);
642
OUTPUT ("fog: %08lx", debug.tri_sel->fog_color);
643
OUTPUT ("prim_lodmin: %d", debug.tri_sel->prim_lodmin);
644
OUTPUT ("prim_lodfrac: %d", debug.tri_sel->prim_lodfrac);
645
}
646
if (debug.page == PAGE_FBL && debug.tri_sel)
647
{
648
COL_CATEGORY();
649
OUTPUT ("BLENDER", 0);
650
COL_TEXT();
651
OUTPUT ("fbl_a0: %s", FBLa[(debug.tri_sel->othermode_l>>30)&0x3]);
652
OUTPUT ("fbl_b0: %s", FBLb[(debug.tri_sel->othermode_l>>26)&0x3]);
653
OUTPUT ("fbl_c0: %s", FBLc[(debug.tri_sel->othermode_l>>22)&0x3]);
654
OUTPUT ("fbl_d0: %s", FBLd[(debug.tri_sel->othermode_l>>18)&0x3]);
655
OUTPUT ("fbl_a1: %s", FBLa[(debug.tri_sel->othermode_l>>28)&0x3]);
656
OUTPUT ("fbl_b1: %s", FBLb[(debug.tri_sel->othermode_l>>24)&0x3]);
657
OUTPUT ("fbl_c1: %s", FBLc[(debug.tri_sel->othermode_l>>20)&0x3]);
658
OUTPUT ("fbl_d1: %s", FBLd[(debug.tri_sel->othermode_l>>16)&0x3]);
659
OUTPUT ("", 0);
660
OUTPUT ("fbl: %08lx", debug.tri_sel->othermode_l&0xFFFF0000);
661
OUTPUT ("fbl #1: %08lx", debug.tri_sel->othermode_l&0xCCCC0000);
662
OUTPUT ("fbl #2: %08lx", debug.tri_sel->othermode_l&0x33330000);
663
}
664
if (debug.page == PAGE_OTHERMODE_L && debug.tri_sel)
665
{
666
DWORD othermode_l = debug.tri_sel->othermode_l;
667
COL_CATEGORY ();
668
OUTPUT ("OTHERMODE_L: %08lx", othermode_l);
669
OUTPUT_ ("AC_NONE", (othermode_l & 3) == 0);
670
_OUTPUT ("AC_THRESHOLD", (othermode_l & 3) == 1);
671
_OUTPUT ("AC_DITHER", (othermode_l & 3) == 3);
672
i -= 16;
673
OUTPUT_ ("ZS_PIXEL", !(othermode_l & 4));
674
_OUTPUT ("ZS_PRIM", (othermode_l & 4));
675
i -= 32;
676
COL_CATEGORY ();
677
OUTPUT ("RENDERMODE: %08lx", othermode_l);
678
OUTPUT_ ("AA_EN", othermode_l & 0x08);
679
i -= 16;
680
OUTPUT_ ("Z_CMP", othermode_l & 0x10);
681
i -= 16;
682
OUTPUT_ ("Z_UPD", othermode_l & 0x20);
683
i -= 16;
684
OUTPUT_ ("IM_RD", othermode_l & 0x40);
685
i -= 16;
686
OUTPUT_ ("CLR_ON_CVG", othermode_l & 0x80);
687
i -= 16;
688
OUTPUT_ ("CVG_DST_CLAMP", (othermode_l & 0x300) == 0x000);
689
_OUTPUT ("CVG_DST_WRAP", (othermode_l & 0x300) == 0x100);
690
_OUTPUT (".._FULL", (othermode_l & 0x300) == 0x200);
691
_OUTPUT (".._SAVE", (othermode_l & 0x300) == 0x300);
692
i -= 16;
693
OUTPUT_ ("ZM_OPA", (othermode_l & 0xC00) == 0x000);
694
_OUTPUT ("ZM_INTER", (othermode_l & 0xC00) == 0x400);
695
_OUTPUT ("ZM_XLU", (othermode_l & 0xC00) == 0x800);
696
_OUTPUT ("ZM_DEC", (othermode_l & 0xC00) == 0xC00);
697
i -= 16;
698
OUTPUT_ ("CVG_X_ALPHA", othermode_l & 0x1000);
699
i -= 16;
700
OUTPUT_ ("ALPHA_CVG_SEL", othermode_l & 0x2000);
701
i -= 16;
702
OUTPUT_ ("FORCE_BL", othermode_l & 0x4000);
703
}
704
if (debug.page == PAGE_OTHERMODE_H && debug.tri_sel)
705
{
706
DWORD othermode_h = debug.tri_sel->othermode_h;
707
COL_CATEGORY ();
708
OUTPUT ("OTHERMODE_H: %08lx", othermode_h);
709
OUTPUT_ ("CK_NONE", (othermode_h & 0x100) == 0);
710
_OUTPUT ("CK_KEY", (othermode_h & 0x100) == 1);
711
i -= 16;
712
OUTPUT_ ("TC_CONV", (othermode_h & 0xE00) == 0x200);
713
_OUTPUT ("TC_FILTCONV", (othermode_h & 0xE00) == 0xA00);
714
_OUTPUT ("TC_FILT", (othermode_h & 0xE00) == 0xC00);
715
i -= 16;
716
OUTPUT_ ("TF_POINT", (othermode_h & 0x3000) == 0x0000);
717
_OUTPUT ("TF_AVERAGE", (othermode_h & 0x3000) == 0x3000);
718
_OUTPUT ("TF_BILERP", (othermode_h & 0x3000) == 0x2000);
719
i -= 16;
720
OUTPUT_ ("TT_NONE", (othermode_h & 0xC000) == 0x0000);
721
_OUTPUT ("TT_RGBA16", (othermode_h & 0xC000) == 0x8000);
722
_OUTPUT ("TT_IA16", (othermode_h & 0xC000) == 0xC000);
723
i -= 16;
724
OUTPUT_ ("TL_TILE", (othermode_h & 0x10000) == 0x00000);
725
_OUTPUT ("TL_LOD", (othermode_h & 0x10000) == 0x10000);
726
i -= 16;
727
OUTPUT_ ("TD_CLAMP", (othermode_h & 0x60000) == 0x00000);
728
_OUTPUT ("TD_SHARPEN", (othermode_h & 0x60000) == 0x20000);
729
_OUTPUT ("TD_DETAIL", (othermode_h & 0x60000) == 0x40000);
730
i -= 16;
731
OUTPUT_ ("TP_NONE", (othermode_h & 0x80000) == 0x00000);
732
_OUTPUT ("TP_PERSP", (othermode_h & 0x80000) == 0x80000);
733
i -= 16;
734
OUTPUT_ ("1CYCLE", (othermode_h & 0x300000) == 0x000000);
735
_OUTPUT ("2CYCLE", (othermode_h & 0x300000) == 0x100000);
736
_OUTPUT ("COPY", (othermode_h & 0x300000) == 0x200000);
737
_OUTPUT ("FILL", (othermode_h & 0x300000) == 0x300000);
738
i -= 16;
739
OUTPUT_ ("PM_1PRIM", (othermode_h & 0x400000) == 0x000000);
740
_OUTPUT ("PM_NPRIM", (othermode_h & 0x400000) == 0x400000);
741
}
742
if (debug.page == PAGE_TEXELS && debug.tri_sel)
743
{
744
// change these to output whatever you need, ou for triangles, or u0 for texrects
745
COL_TEXT();
746
OUTPUT ("n: %d", debug.tri_sel->nv);
747
OUTPUT ("",0);
748
for (j=0; j<debug.tri_sel->nv; j++)
749
{
750
OUTPUT1 ("v[%d].s0: %f", j, debug.tri_sel->v[j].ou);
751
OUTPUT1 ("v[%d].t0: %f", j, debug.tri_sel->v[j].ov);
752
}
753
OUTPUT ("",0);
754
for (j=0; j<debug.tri_sel->nv; j++)
755
{
756
OUTPUT1 ("v[%d].s1: %f", j, debug.tri_sel->v[j].u0);
757
OUTPUT1 ("v[%d].t1: %f", j, debug.tri_sel->v[j].v0);
758
}
759
}
760
if (debug.page == PAGE_COORDS && debug.tri_sel)
761
{
762
COL_TEXT();
763
OUTPUT ("n: %d", debug.tri_sel->nv);
764
for (j=0; j<debug.tri_sel->nv; j++)
765
{
766
OUTPUT1 ("v[%d].x: %f", j, debug.tri_sel->v[j].x);
767
OUTPUT1 ("v[%d].y: %f", j, debug.tri_sel->v[j].y);
768
OUTPUT1 ("v[%d].z: %f", j, debug.tri_sel->v[j].z);
769
OUTPUT1 ("v[%d].w: %f", j, debug.tri_sel->v[j].w);
770
OUTPUT1 ("v[%d].f: %f", j, 1.0f/debug.tri_sel->v[j].f);
771
OUTPUT1 ("v[%d].r: %d", j, debug.tri_sel->v[j].r);
772
OUTPUT1 ("v[%d].g: %d", j, debug.tri_sel->v[j].g);
773
OUTPUT1 ("v[%d].b: %d", j, debug.tri_sel->v[j].b);
774
OUTPUT1 ("v[%d].a: %d", j, debug.tri_sel->v[j].a);
775
}
776
}
777
if (debug.page == PAGE_TEX_INFO && debug.tex_sel < (DWORD)rdp.n_cached[debug.tmu])
778
{
779
COL_CATEGORY();
780
OUTPUT ("CACHE (page 0)", 0);
781
COL_TEXT();
782
//OUTPUT ("t_mem: %08lx", rdp.cache[0][debug.tex_sel].t_mem);
783
//OUTPUT ("crc: %08lx", rdp.cache[0][debug.tex_sel].crc);
784
OUTPUT ("addr: %08lx", rdp.cache[debug.tmu][debug.tex_sel].addr);
785
OUTPUT ("scale_x: %f", rdp.cache[debug.tmu][debug.tex_sel].scale_x);
786
OUTPUT ("scale_y: %f", rdp.cache[debug.tmu][debug.tex_sel].scale_y);
787
OUTPUT ("tmem_addr: %08lx", rdp.cache[debug.tmu][debug.tex_sel].tmem_addr);
788
OUTPUT ("palette: %08lx", rdp.cache[debug.tmu][debug.tex_sel].palette);
789
OUTPUT ("set_by: %08lx", rdp.cache[debug.tmu][debug.tex_sel].set_by);
790
OUTPUT ("texrecting: %d", rdp.cache[debug.tmu][debug.tex_sel].texrecting);
791
792
OUTPUT ("mod: %08lx", rdp.cache[debug.tmu][debug.tex_sel].mod);
793
OUTPUT ("mod_col: %08lx", rdp.cache[debug.tmu][debug.tex_sel].mod_color);
794
OUTPUT ("mod_col1: %08lx", rdp.cache[debug.tmu][debug.tex_sel].mod_color1);
795
i=740;
796
output(800,(float)i,1,"width: %d", rdp.cache[debug.tmu][debug.tex_sel].width);
797
i-=16;
798
output(800,(float)i,1,"height: %d", rdp.cache[debug.tmu][debug.tex_sel].height);
799
i-=16;
800
output(800,(float)i,1,"format: %d", rdp.cache[debug.tmu][debug.tex_sel].format);
801
i-=16;
802
output(800,(float)i,1,"size: %d", rdp.cache[debug.tmu][debug.tex_sel].size);
803
i-=16;
804
output(800,(float)i,1,"crc: %08lx", rdp.cache[debug.tmu][debug.tex_sel].crc);
805
i-=16;
806
output(800,(float)i,1,"line: %d", rdp.cache[debug.tmu][debug.tex_sel].line);
807
i-=16;
808
output(800,(float)i,1,"mod_factor: %08lx", rdp.cache[debug.tmu][debug.tex_sel].mod_factor);
809
i-=32;
810
811
output(800,(float)i,1,"lod: %s", str_lod[rdp.cache[debug.tmu][debug.tex_sel].lod]);
812
i-=16;
813
output(800,(float)i,1,"aspect: %s", str_aspect[rdp.cache[debug.tmu][debug.tex_sel].aspect + 3]);
814
815
// debug_texture(debug.tmu, rdp.cache[debug.tmu][debug.tex_sel].addr, debug.tex_sel);
816
}
817
818
// Draw the vertex numbers
819
if (debug.tri_sel)
820
{
821
for (i=0; i<debug.tri_sel->nv; i++)
822
{
823
grConstantColorValue (0x000000FF);
824
output (debug.tri_sel->v[i].x+1, settings.scr_res_y-debug.tri_sel->v[i].y+1, 1,
825
"%d", i);
826
grConstantColorValue (0xFFFFFFFF);
827
output (debug.tri_sel->v[i].x, settings.scr_res_y-debug.tri_sel->v[i].y, 1,
828
"%d", i);
829
}
830
}
831
832
// Draw the cursor
833
debug_mouse ();
834
835
grBufferSwap (1);
836
}
837
838
END:
839
// Release all data
840
delete [] debug.screen;
841
TRI_INFO *tri;
842
for (tri=debug.tri_list; tri != debug.tri_last;)
843
{
844
TRI_INFO *tmp = tri;
845
tri = tri->pNext;
846
delete [] tmp->v;
847
delete tmp;
848
}
849
delete [] tri->v;
850
delete tri;
851
852
// Reset all values
853
debug.capture = 0;
854
debug.selected = SELECTED_TRI;
855
debug.screen = NULL;
856
debug.tri_list = NULL;
857
debug.tri_last = NULL;
858
debug.tri_sel = NULL;
859
debug.tex_sel = 0;
860
}
861
862
//
863
// debug_mouse - draws the debugger mouse
864
//
865
866
void debug_mouse ()
867
{
868
grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
869
GR_COMBINE_FACTOR_ONE,
870
GR_COMBINE_LOCAL_NONE,
871
GR_COMBINE_OTHER_TEXTURE,
872
FXFALSE);
873
874
grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
875
GR_COMBINE_FACTOR_ONE,
876
GR_COMBINE_LOCAL_NONE,
877
GR_COMBINE_OTHER_TEXTURE,
878
FXFALSE);
879
880
// Draw the cursor
881
POINT pt;
882
GetCursorPos (&pt);
883
float cx = (float)pt.x;
884
float cy = (float)pt.y;
885
886
VERTEX v[4] = {
887
{ cx, cy, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
888
{ cx+32, cy, 1, 1, 255, 0, 0, 0, 0, 0, 0 },
889
{ cx, cy+32, 1, 1, 0, 255, 0, 0, 0, 0, 0 },
890
{ cx+32, cy+32, 1, 1, 255, 255, 0, 0, 0, 0, 0 } };
891
892
ConvertCoordsKeep (v, 4);
893
894
grTexSource(GR_TMU0,
895
grTexMinAddress(GR_TMU0) + offset_cursor,
896
GR_MIPMAPLEVELMASK_BOTH,
897
&cursorTex);
898
899
if (num_tmu >= 3)
900
grTexCombine (GR_TMU2,
901
GR_COMBINE_FUNCTION_NONE,
902
GR_COMBINE_FACTOR_NONE,
903
GR_COMBINE_FUNCTION_NONE,
904
GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
905
if (num_tmu >= 2)
906
grTexCombine (GR_TMU1,
907
GR_COMBINE_FUNCTION_NONE,
908
GR_COMBINE_FACTOR_NONE,
909
GR_COMBINE_FUNCTION_NONE,
910
GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
911
grTexCombine (GR_TMU0,
912
GR_COMBINE_FUNCTION_LOCAL,
913
GR_COMBINE_FACTOR_NONE,
914
GR_COMBINE_FUNCTION_LOCAL,
915
GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
916
917
grDrawTriangle (&v[0], &v[1], &v[2]);
918
grDrawTriangle (&v[1], &v[3], &v[2]);
919
}
920
921
//
922
// debug_keys - receives debugger key input
923
//
924
925
void debug_keys ()
926
{
927
if ((GetAsyncKeyState (VK_RIGHT) & 0x0001) && debug.tri_sel)
928
{
929
TRI_INFO *start = debug.tri_sel;
930
931
while (debug.tri_sel->pNext != start)
932
debug.tri_sel = debug.tri_sel->pNext;
933
}
934
935
if ((GetAsyncKeyState (VK_LEFT) & 0x0001) && debug.tri_sel)
936
debug.tri_sel = debug.tri_sel->pNext;
937
938
// Check for page changes
939
if (GetAsyncKeyState ('1') & 0x0001)
940
debug.page = PAGE_GENERAL;
941
if (GetAsyncKeyState ('2') & 0x0001)
942
debug.page = PAGE_TEX1;
943
if (GetAsyncKeyState ('3') & 0x0001)
944
debug.page = PAGE_TEX2;
945
if (GetAsyncKeyState ('4') & 0x0001)
946
debug.page = PAGE_COLORS;
947
if (GetAsyncKeyState ('5') & 0x0001)
948
debug.page = PAGE_FBL;
949
if (GetAsyncKeyState ('6') & 0x0001)
950
debug.page = PAGE_OTHERMODE_L;
951
if (GetAsyncKeyState ('7') & 0x0001)
952
debug.page = PAGE_OTHERMODE_H;
953
if (GetAsyncKeyState ('8') & 0x0001)
954
debug.page = PAGE_TEXELS;
955
if (GetAsyncKeyState ('9') & 0x0001)
956
debug.page = PAGE_COORDS;
957
if (GetAsyncKeyState ('0') & 0x0001)
958
debug.page = PAGE_TEX_INFO;
959
if (GetAsyncKeyState ('Q') & 0x0001)
960
debug.tmu = 0;
961
if (GetAsyncKeyState ('W') & 0x0001)
962
debug.tmu = 1;
963
964
if (GetAsyncKeyState ('G') & 0x0001)
965
grid = !grid;
966
967
// Go to texture
968
if (GetAsyncKeyState (VK_SPACE) & 0x0001)
969
{
970
int tile = -1;
971
if (debug.page == PAGE_TEX2)
972
tile = 1;
973
else
974
tile = 0;
975
if (tile != -1)
976
{
977
debug.tmu = debug.tri_sel->t[tile].tmu;
978
debug.tex_sel = debug.tri_sel->t[tile].cur_cache[debug.tmu];
979
debug.tex_scroll = (debug.tri_sel->t[tile].cur_cache[debug.tmu] >> 4) - 1;
980
}
981
}
982
983
// Go to triangle
984
if (GetAsyncKeyState (VK_LCONTROL) & 0x0001)
985
{
986
int count = rdp.debug_n - rdp.cache[debug.tmu][debug.tex_sel].uses - 1;
987
if (rdp.cache[debug.tmu][debug.tex_sel].last_used == frame_count)
988
{
989
TRI_INFO *t = debug.tri_list;
990
while (count && t) {
991
t = t->pNext;
992
count --;
993
}
994
debug.tri_sel = t;
995
}
996
else
997
debug.tri_sel = NULL;
998
}
999
1000
if (GetAsyncKeyState ('A') & 0x0001)
1001
debug.draw_mode = 0; // texture & texture alpha
1002
if (GetAsyncKeyState ('S') & 0x0001)
1003
debug.draw_mode = 1; // texture
1004
if (GetAsyncKeyState ('D') & 0x0001)
1005
debug.draw_mode = 2; // texture alpha
1006
1007
// Check for texture scrolling
1008
if (GetAsyncKeyState (VK_DOWN) & 0x0001)
1009
debug.tex_scroll ++;
1010
if (GetAsyncKeyState (VK_UP) & 0x0001)
1011
debug.tex_scroll --;
1012
}
1013
#endif // _WIN32
1014
//
1015
// output - output debugger text
1016
//
1017
1018
void output (float x, float y, BOOL scale, const char *fmt, ...)
1019
{
1020
va_list ap;
1021
va_start(ap,fmt);
1022
vsprintf(out_buf, fmt, ap);
1023
va_end(ap);
1024
1025
BYTE c,r;
1026
for (DWORD i=0; i<strlen(out_buf); i++)
1027
{
1028
c = ((out_buf[i]-32) & 0x1F) * 8;//<< 3;
1029
r = (((out_buf[i]-32) & 0xE0) >> 5) * 16;//<< 4;
1030
VERTEX v[4] = { { SX(x), SY(768-y), 1, 1, (float)c, r+16.0f, 0, 0, {0, 0, 0, 0} },
1031
{ SX(x+8), SY(768-y), 1, 1, c+8.0f, r+16.0f, 0, 0, {0, 0, 0, 0} },
1032
{ SX(x), SY(768-y-16), 1, 1, (float)c, (float)r, 0, 0, {0, 0, 0, 0} },
1033
{ SX(x+8), SY(768-y-16), 1, 1, c+8.0f, (float)r, 0, 0, {0, 0, 0, 0} } };
1034
if (!scale)
1035
{
1036
v[0].x = x;
1037
v[0].y = y;
1038
v[1].x = x+8;
1039
v[1].y = y;
1040
v[2].x = x;
1041
v[2].y = y-16;
1042
v[3].x = x+8;
1043
v[3].y = y-16;
1044
}
1045
1046
ConvertCoordsKeep (v, 4);
1047
1048
grDrawTriangle (&v[0], &v[1], &v[2]);
1049
grDrawTriangle (&v[1], &v[3], &v[2]);
1050
1051
x+=8;
1052
}
1053
}
1054
1055
1056