Replace Tmem_nasm.asm with C++ code. Patch by pyro.
[Glide64.git] / UcodeFB.h
blob9edb8dd4c64dca3f5d065eff676ec8d28085a2df
1 /*
2 * Glide64 - Glide video plugin for Nintendo 64 emulators.
3 * Copyright (c) 2002 Dave2001
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //****************************************************************
22 // Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
23 // Project started on December 29th, 2001
25 // To modify Glide64:
26 // * 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.
27 // * 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 // Official Glide64 development channel: #Glide64 on EFnet
31 // Original author: Dave2001 (Dave2999@hotmail.com)
32 // Other authors: Gonetz, Gugaman
34 //****************************************************************
36 // Creation 13 August 2003 Gonetz
38 //****************************************************************
40 #ifndef _WIN32
41 #include <stdlib.h>
42 #endif
44 static void fb_uc0_moveword()
46 if ((rdp.cmd0 & 0xFF) == 0x06) // segment
48 rdp.segment[(rdp.cmd0 >> 10) & 0x0F] = rdp.cmd1;
52 static void fb_uc2_moveword()
54 if (((rdp.cmd0 >> 16) & 0xFF) == 0x06) // segment
56 rdp.segment[((rdp.cmd0 & 0xFFFF) >> 2)&0xF] = rdp.cmd1;
60 static void fb_bg_copy ()
62 if (rdp.main_ci == 0)
63 return;
64 CI_STATUS status = rdp.frame_buffers[rdp.ci_count-1].status;
65 if ( (status == ci_copy) )
66 return;
68 DWORD addr = segoffset(rdp.cmd1) >> 1;
69 BYTE imageFmt = ((BYTE *)gfx.RDRAM)[(((addr+11)<<1)+0)^3];
70 BYTE imageSiz = ((BYTE *)gfx.RDRAM)[(((addr+11)<<1)+1)^3];
71 DWORD imagePtr = segoffset(((DWORD*)gfx.RDRAM)[(addr+8)>>1]);
72 FRDP ("fb_bg_copy. fmt: %d, size: %d, imagePtr %08lx, main_ci: %08lx, cur_ci: %08lx \n", imageFmt, imageSiz, imagePtr, rdp.main_ci, rdp.frame_buffers[rdp.ci_count-1].addr);
74 if (status == ci_main)
76 WORD frameW = ((WORD *)gfx.RDRAM)[(addr+3)^1] >> 2;
77 WORD frameH = ((WORD *)gfx.RDRAM)[(addr+7)^1] >> 2;
78 if ( (frameW == rdp.frame_buffers[rdp.ci_count-1].width) && (frameH == rdp.frame_buffers[rdp.ci_count-1].height) )
79 rdp.main_ci_bg = imagePtr;
81 else if (imagePtr >= rdp.main_ci && imagePtr < rdp.main_ci_end) //addr within main frame buffer
83 rdp.copy_ci_index = rdp.ci_count-1;
84 rdp.frame_buffers[rdp.copy_ci_index].status = ci_copy;
85 FRDP("rdp.frame_buffers[%d].status = ci_copy\n", rdp.copy_ci_index);
87 if (rdp.frame_buffers[rdp.copy_ci_index].addr != rdp.main_ci_bg)
89 rdp.scale_x = 1.0f;
90 rdp.scale_y = 1.0f;
92 else
94 RDP("motion blur!\n");
95 rdp.motionblur = TRUE;
98 FRDP ("Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx \n", imagePtr, rdp.main_ci);
100 else if (imagePtr == rdp.zimg)
102 //printf("toto !\n");
103 if (status == ci_unknown)
105 rdp.frame_buffers[rdp.ci_count-1].status = ci_zimg;
106 rdp.tmpzimg = rdp.frame_buffers[rdp.ci_count-1].addr;
107 FRDP("rdp.frame_buffers[%d].status = ci_zimg\n", rdp.copy_ci_index);
112 static void fb_setscissor()
114 rdp.scissor_o.lr_y = (((rdp.cmd1 & 0x00000FFF) >> 2));
115 if (rdp.ci_count)
117 rdp.scissor_o.ul_x = (((rdp.cmd0 & 0x00FFF000) >> 14));
118 rdp.scissor_o.lr_x = (((rdp.cmd1 & 0x00FFF000) >> 14));
119 COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count-1];
120 if (rdp.scissor_o.lr_x - rdp.scissor_o.ul_x > (cur_fb.width >> 1))
122 if (cur_fb.height == 0 || (cur_fb.width >= rdp.scissor_o.lr_x-1 && cur_fb.width <= rdp.scissor_o.lr_x+1))
123 cur_fb.height = rdp.scissor_o.lr_y;
125 FRDP("fb_setscissor. lr_x = %d, lr_y = %d, fb_width = %d, fb_height = %d\n", rdp.scissor_o.lr_x, rdp.scissor_o.lr_y, cur_fb.width, cur_fb.height);
129 static void fb_rect()
131 if (rdp.frame_buffers[rdp.ci_count-1].width == 32)
132 return;
133 int ul_x = ((rdp.cmd1 & 0x00FFF000) >> 14);
134 int lr_x = ((rdp.cmd0 & 0x00FFF000) >> 14);
135 int width = lr_x-ul_x;
136 DWORD lr_y = ((rdp.cmd0 & 0x00000FFF) >> 2);
137 int diff = abs((int)rdp.frame_buffers[rdp.ci_count-1].width - width);
138 if (diff < 4)
139 if (rdp.frame_buffers[rdp.ci_count-1].height < lr_y)
141 FRDP("fb_rect. ul_x: %d, lr_x: %d, fb_height: %d -> %d\n", ul_x, lr_x, rdp.frame_buffers[rdp.ci_count-1].height, lr_y);
142 rdp.frame_buffers[rdp.ci_count-1].height = lr_y;
146 static void fb_settextureimage()
148 if (rdp.main_ci == 0)
149 return;
150 COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count-1];
151 if ( cur_fb.status >= ci_copy )
152 return;
153 if (((rdp.cmd0 >> 19) & 0x03) >= 2) //check that texture is 16/32bit
155 int tex_format = ((rdp.cmd0 >> 21) & 0x07);
156 DWORD addr = segoffset(rdp.cmd1);
157 if ( tex_format == 0 )
159 FRDP ("fb_settextureimage. fmt: %d, size: %d, imagePtr %08lx, main_ci: %08lx, cur_ci: %08lx \n", ((rdp.cmd0 >> 21) & 0x07), ((rdp.cmd0 >> 19) & 0x03), addr, rdp.main_ci, rdp.frame_buffers[rdp.ci_count-1].addr);
160 if (cur_fb.status == ci_main)
162 rdp.main_ci_last_tex_addr = addr;
163 if (cur_fb.height == 0)
165 cur_fb.height = rdp.scissor_o.lr_y;
166 rdp.main_ci_end = cur_fb.addr + ((cur_fb.width * cur_fb.height) << cur_fb.size >> 1);
169 if ((addr >= rdp.main_ci) && (addr < rdp.main_ci_end)) //addr within main frame buffer
171 if (cur_fb.status == ci_main)
173 rdp.copy_ci_index = rdp.ci_count-1;
174 cur_fb.status = ci_copy_self;
175 rdp.scale_x = rdp.scale_x_bak;
176 rdp.scale_y = rdp.scale_y_bak;
177 FRDP("rdp.frame_buffers[%d].status = ci_copy_self\n", rdp.ci_count-1);
179 else
181 if (cur_fb.width == rdp.frame_buffers[rdp.main_ci_index].width)
183 rdp.copy_ci_index = rdp.ci_count-1;
184 cur_fb.status = ci_copy;
185 FRDP("rdp.frame_buffers[%d].status = ci_copy\n", rdp.copy_ci_index);
186 if ((rdp.main_ci_last_tex_addr >= cur_fb.addr) &&
187 (rdp.main_ci_last_tex_addr < (cur_fb.addr + cur_fb.width*cur_fb.height*cur_fb.size)))
189 RDP("motion blur!\n");
190 rdp.motionblur = TRUE;
192 else
194 rdp.scale_x = 1.0f;
195 rdp.scale_y = 1.0f;
198 else if (!settings.fb_ignore_aux_copy && cur_fb.width < rdp.frame_buffers[rdp.main_ci_index].width)
200 rdp.copy_ci_index = rdp.ci_count-1;
201 cur_fb.status = ci_aux_copy;
202 FRDP("rdp.frame_buffers[%d].status = ci_aux_copy\n", rdp.copy_ci_index);
203 rdp.scale_x = 1.0f;
204 rdp.scale_y = 1.0f;
206 else
208 cur_fb.status = ci_aux;
209 FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.copy_ci_index);
212 FRDP ("Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx \n", addr, rdp.main_ci);
214 ///*
215 else if ((cur_fb.status != ci_main) && (addr >= rdp.zimg && addr < rdp.zimg_end))
217 cur_fb.status = ci_zcopy;
218 FRDP("fb_settextureimage. rdp.frame_buffers[%d].status = ci_zcopy\n", rdp.ci_count-1);
220 //*/
221 else if ((addr >= rdp.maincimg[0].addr) && (addr < (rdp.maincimg[0].addr + rdp.maincimg[0].width*rdp.maincimg[0].height*2)))
223 if (cur_fb.status != ci_main)
225 cur_fb.status = ci_old_copy;
226 FRDP("rdp.frame_buffers[%d].status = ci_old_copy 1, addr:%08lx\n", rdp.ci_count-1, rdp.last_drawn_ci_addr);
228 rdp.read_previous_ci = TRUE;
229 RDP("read_previous_ci = TRUE\n");
231 else if ((addr >= rdp.last_drawn_ci_addr) && (addr < (rdp.last_drawn_ci_addr + rdp.maincimg[0].width*rdp.maincimg[0].height*2)))
233 if (cur_fb.status != ci_main)
235 cur_fb.status = ci_old_copy;
236 FRDP("rdp.frame_buffers[%d].status = ci_old_copy 2, addr:%08lx\n", rdp.ci_count-1, rdp.last_drawn_ci_addr);
238 rdp.read_previous_ci = TRUE;
239 RDP("read_previous_ci = TRUE\n");
242 else if (settings.fb_hires && (cur_fb.status == ci_main))
244 if ((addr >= rdp.main_ci) && (addr < rdp.main_ci_end)) //addr within main frame buffer
246 rdp.copy_ci_index = rdp.ci_count-1;
247 rdp.black_ci_index = rdp.ci_count-1;
248 cur_fb.status = ci_copy_self;
249 FRDP("rdp.frame_buffers[%d].status = ci_copy_self\n", rdp.ci_count-1);
253 if (cur_fb.status == ci_unknown)
255 cur_fb.status = ci_aux;
256 FRDP("fb_settextureimage. rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count-1);
260 static void fb_loadtxtr()
262 if (rdp.frame_buffers[rdp.ci_count-1].status == ci_unknown)
264 rdp.frame_buffers[rdp.ci_count-1].status = ci_aux;
265 FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count-1);
269 static void fb_setdepthimage()
271 rdp.zimg = segoffset(rdp.cmd1) & BMASK;
272 rdp.zimg_end = rdp.zimg + rdp.ci_width*rdp.ci_height*2;
273 FRDP ("fb_setdepthimage. addr %08lx - %08lx\n", rdp.zimg, rdp.zimg_end);
274 if (rdp.zimg == rdp.main_ci) //strange, but can happen
276 rdp.frame_buffers[rdp.main_ci_index].status = ci_unknown;
277 if (rdp.main_ci_index < rdp.ci_count)
279 rdp.frame_buffers[rdp.main_ci_index].status = ci_zimg;
280 FRDP("rdp.frame_buffers[%d].status = ci_zimg\n", rdp.main_ci_index);
281 rdp.main_ci_index++;
282 rdp.frame_buffers[rdp.main_ci_index].status = ci_main;
283 FRDP("rdp.frame_buffers[%d].status = ci_main\n", rdp.main_ci_index);
284 rdp.main_ci = rdp.frame_buffers[rdp.main_ci_index].addr;
285 rdp.main_ci_end = rdp.main_ci + (rdp.frame_buffers[rdp.main_ci_index].width * rdp.frame_buffers[rdp.main_ci_index].height * rdp.frame_buffers[rdp.main_ci_index].size);
287 else
289 rdp.main_ci = 0;
292 for (int i = 0; i < rdp.ci_count; i++)
294 COLOR_IMAGE & fb = rdp.frame_buffers[i];
295 if ((fb.addr == rdp.zimg) && (fb.status == ci_aux || fb.status == ci_useless))
297 fb.status = ci_zimg;
298 FRDP("rdp.frame_buffers[%d].status = ci_zimg\n", i);
303 static void fb_setcolorimage()
305 rdp.ocimg = rdp.cimg;
306 rdp.cimg = segoffset(rdp.cmd1) & BMASK;
307 COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count];
308 cur_fb.width = (rdp.cmd0 & 0xFFF) + 1;
309 if (cur_fb.width == 32 )
310 cur_fb.height = 32;
311 else if (cur_fb.width == 16 )
312 cur_fb.height = 16;
313 else if (rdp.ci_count > 0)
314 cur_fb.height = rdp.scissor_o.lr_y;
315 else
316 cur_fb.height = 0;
317 cur_fb.format = (rdp.cmd0 >> 21) & 0x7;
318 cur_fb.size = (rdp.cmd0 >> 19) & 0x3;
319 cur_fb.addr = rdp.cimg;
320 cur_fb.changed = 1;
322 if (rdp.ci_count > 0)
323 if (rdp.frame_buffers[0].addr == rdp.cimg)
324 rdp.frame_buffers[0].height = rdp.scissor_o.lr_y;
326 FRDP ("fb_setcolorimage. width: %d, height: %d, fmt: %d, size: %d, addr %08lx\n", cur_fb.width, cur_fb.height, cur_fb.format, cur_fb.size, cur_fb.addr);
327 if ((rdp.cimg == rdp.zimg) || (rdp.cimg == rdp.tmpzimg))
329 cur_fb.status = ci_zimg;
330 if (rdp.zimg_end == rdp.zimg)
331 rdp.zimg_end = rdp.zimg + cur_fb.width*rdp.scissor_o.lr_y*2;
332 FRDP("rdp.frame_buffers[%d].status = ci_zimg\n", rdp.ci_count);
334 else if (rdp.main_ci != 0)
336 if (rdp.cimg == rdp.main_ci) //switched to main fb again
338 cur_fb.height = max(cur_fb.height, rdp.frame_buffers[rdp.main_ci_index].height);
339 rdp.main_ci_index = rdp.ci_count;
340 rdp.main_ci_end = rdp.cimg + ((cur_fb.width * cur_fb.height) << cur_fb.size >> 1);
341 cur_fb.status = ci_main;
342 FRDP("rdp.frame_buffers[%d].status = ci_main\n", rdp.ci_count);
344 else // status is not known yet
346 cur_fb.status = ci_unknown;
349 else
351 if ((rdp.zimg != rdp.cimg))//&& (rdp.ocimg != rdp.cimg))
353 rdp.main_ci = rdp.cimg;
354 rdp.main_ci_end = rdp.cimg + ((cur_fb.width * cur_fb.height) << cur_fb.size >> 1);
355 rdp.main_ci_index = rdp.ci_count;
356 cur_fb.status = ci_main;
357 FRDP("rdp.frame_buffers[%d].status = ci_main\n", rdp.ci_count);
359 else
361 cur_fb.status = ci_unknown;
365 if (rdp.frame_buffers[rdp.ci_count-1].status == ci_unknown) //status of previous fb was not changed - it is useless
367 if (settings.fb_hires && !settings.PM)
369 rdp.frame_buffers[rdp.ci_count-1].status = ci_aux;
370 rdp.frame_buffers[rdp.ci_count-1].changed = 0;
371 FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count-1);
373 else
375 rdp.frame_buffers[rdp.ci_count-1].status = ci_useless;
377 DWORD addr = rdp.frame_buffers[rdp.ci_count-1].addr;
378 for (int i = 0; i < rdp.ci_count - 1; i++)
380 if (rdp.frame_buffers[i].addr == addr)
382 rdp.frame_buffers[rdp.ci_count-1].status = rdp.frame_buffers[i].status;
383 break;
386 //*/
387 FRDP("rdp.frame_buffers[%d].status = %s\n", rdp.ci_count-1, CIStatus[rdp.frame_buffers[rdp.ci_count-1].status]);
390 if (cur_fb.status == ci_main)
392 BOOL viSwapOK = ((settings.swapmode == 2) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE;
393 if ((rdp.maincimg[0].addr != cur_fb.addr) && SwapOK && viSwapOK)
395 SwapOK = FALSE;
396 rdp.swap_ci_index = rdp.ci_count;
399 rdp.ci_count++;
400 if (rdp.ci_count > NUMTEXBUF) //overflow
401 rdp.halt = 1;
404 // RDP graphic instructions pointer table used in DetectFrameBufferUsage
406 static rdp_instr gfx_instruction_lite[9][256] =
409 // uCode 0 - RSP SW 2.0X
410 // 00-3f
411 // games: Super Mario 64, Tetrisphere, Demos
412 0, 0, 0, 0,
413 0, 0, uc0_displaylist, 0,
414 0, 0, 0, 0,
415 0, 0, 0, 0,
416 0, 0, 0, 0,
417 0, 0, 0, 0,
418 0, 0, 0, 0,
419 0, 0, 0, 0,
420 0, 0, 0, 0,
421 0, 0, 0, 0,
422 0, 0, 0, 0,
423 0, 0, 0, 0,
424 0, 0, 0, 0,
425 0, 0, 0, 0,
426 0, 0, 0, 0,
427 0, 0, 0, 0,
428 // 40-7f: Unused
429 0, 0, 0, 0,
430 0, 0, 0, 0,
431 0, 0, 0, 0,
432 0, 0, 0, 0,
433 0, 0, 0, 0,
434 0, 0, 0, 0,
435 0, 0, 0, 0,
436 0, 0, 0, 0,
437 0, 0, 0, 0,
438 0, 0, 0, 0,
439 0, 0, 0, 0,
440 0, 0, 0, 0,
441 0, 0, 0, 0,
442 0, 0, 0, 0,
443 0, 0, 0, 0,
444 0, 0, 0, 0,
445 // 80-bf: Immediate commands
446 0, 0, 0, 0,
447 0, 0, 0, 0,
448 0, 0, 0, 0,
449 0, 0, 0, 0,
450 0, 0, 0, 0,
451 0, 0, 0, 0,
452 0, 0, 0, 0,
453 0, 0, 0, 0,
454 0, 0, 0, 0,
455 0, 0, 0, 0,
456 0, 0, 0, 0,
457 0, 0, 0, 0,
458 0, 0, 0, 0,
459 0, 0, 0, 0,
460 uc0_enddl, 0, 0, 0,
461 fb_uc0_moveword, 0, uc0_culldl, 0,
462 // c0-ff: RDP commands
463 0, 0, 0, 0,
464 0, 0, 0, 0,
465 0, 0, 0, 0,
466 0, 0, 0, 0,
467 0, 0, 0, 0,
468 0, 0, 0, 0,
469 0, 0, 0, 0,
470 0, 0, 0, 0,
471 0, 0, 0, 0,
472 fb_rect, fb_rect, 0, 0,
473 0, 0, 0, 0,
474 0, fb_setscissor, 0, 0,
475 0, 0, 0, 0,
476 0, 0, fb_rect, 0,
477 0, 0, 0, 0,
478 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
481 // uCode 1 - F3DEX 1.XX
482 // 00-3f
483 // games: Mario Kart, Star Fox
485 0, 0, 0, 0,
486 0, 0, uc0_displaylist, 0,
487 0, 0, 0, 0,
488 0, 0, 0, 0,
489 0, 0, 0, 0,
490 0, 0, 0, 0,
491 0, 0, 0, 0,
492 0, 0, 0, 0,
493 0, 0, 0, 0,
494 0, 0, 0, 0,
495 0, 0, 0, 0,
496 0, 0, 0, 0,
497 0, 0, 0, 0,
498 0, 0, 0, 0,
499 0, 0, 0, 0,
500 0, 0, 0, 0,
501 // 40-7f: unused
502 0, 0, 0, 0,
503 0, 0, 0, 0,
504 0, 0, 0, 0,
505 0, 0, 0, 0,
506 0, 0, 0, 0,
507 0, 0, 0, 0,
508 0, 0, 0, 0,
509 0, 0, 0, 0,
510 0, 0, 0, 0,
511 0, 0, 0, 0,
512 0, 0, 0, 0,
513 0, 0, 0, 0,
514 0, 0, 0, 0,
515 0, 0, 0, 0,
516 0, 0, 0, 0,
517 0, 0, 0, 0,
518 // 80-bf: Immediate commands
519 0, 0, 0, 0,
520 0, 0, 0, 0,
521 0, 0, 0, 0,
522 0, 0, 0, 0,
523 0, 0, 0, 0,
524 0, 0, 0, 0,
525 0, 0, 0, 0,
526 0, 0, 0, 0,
527 0, 0, 0, 0,
528 0, 0, 0, 0,
529 0, 0, 0, 0,
530 0, 0, 0, uc6_loaducode,
531 uc1_branch_z, 0, 0, 0,
532 uc1_rdphalf_1, 0, 0, 0,
533 uc0_enddl, 0, 0, 0,
534 fb_uc0_moveword, 0, uc2_culldl, 0,
535 // c0-ff: RDP commands
536 0, 0, 0, 0,
537 0, 0, 0, 0,
538 0, 0, 0, 0,
539 0, 0, 0, 0,
540 0, 0, 0, 0,
541 0, 0, 0, 0,
542 0, 0, 0, 0,
543 0, 0, 0, 0,
544 0, 0, 0, 0,
545 fb_rect, fb_rect, 0, 0,
546 0, 0, 0, 0,
547 0, fb_setscissor, 0, 0,
548 0, 0, 0, 0,
549 0, 0, fb_rect, 0,
550 0, 0, 0, 0,
551 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
554 // uCode 2 - F3DEX 2.XX
555 // games: Zelda 64
557 // 00-3f
558 0, 0, 0, uc2_culldl,
559 uc1_branch_z, 0, 0, 0,
560 0, fb_bg_copy, fb_bg_copy, 0,
561 0, 0, 0, 0,
562 0, 0, 0, 0,
563 0, 0, 0, 0,
564 0, 0, 0, 0,
565 0, 0, 0, 0,
566 0, 0, 0, 0,
567 0, 0, 0, 0,
568 0, 0, 0, 0,
569 0, 0, 0, 0,
570 0, 0, 0, 0,
571 0, 0, 0, 0,
572 0, 0, 0, 0,
573 0, 0, 0, 0,
575 // 40-7f: unused
576 0, 0, 0, 0,
577 0, 0, 0, 0,
578 0, 0, 0, 0,
579 0, 0, 0, 0,
580 0, 0, 0, 0,
581 0, 0, 0, 0,
582 0, 0, 0, 0,
583 0, 0, 0, 0,
584 0, 0, 0, 0,
585 0, 0, 0, 0,
586 0, 0, 0, 0,
587 0, 0, 0, 0,
588 0, 0, 0, 0,
589 0, 0, 0, 0,
590 0, 0, 0, 0,
591 0, 0, 0, 0,
593 // 80-bf: unused
594 0, 0, 0, 0,
595 0, 0, 0, 0,
596 0, 0, 0, 0,
597 0, 0, 0, 0,
598 0, 0, 0, 0,
599 0, 0, 0, 0,
600 0, 0, 0, 0,
601 0, 0, 0, 0,
602 0, 0, 0, 0,
603 0, 0, 0, 0,
604 0, 0, 0, 0,
605 0, 0, 0, 0,
606 0, 0, 0, 0,
607 0, 0, 0, 0,
608 0, 0, 0, 0,
609 0, 0, 0, 0,
611 // c0-ff: RDP commands mixed with uc2 commands
612 0, 0, 0, 0,
613 0, 0, 0, 0,
614 0, 0, 0, 0,
615 0, 0, 0, 0,
616 0, 0, 0, 0,
617 0, uc2_dlist_cnt, 0, 0,
618 0, 0, 0, fb_uc2_moveword,
619 0/*fb_uc2_movemem*/, uc2_load_ucode, uc0_displaylist, uc0_enddl,
620 0, uc1_rdphalf_1, 0, 0,
621 fb_rect, fb_rect, 0, 0,
622 0, 0, 0, 0,
623 0, fb_setscissor, 0, 0,
624 0, 0, 0, 0,
625 0, 0, fb_rect, 0,
626 0, 0, 0, 0,
627 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
630 // uCode 3 - "RSP SW 2.0D", but not really
631 // 00-3f
632 // games: Wave Race
633 // ** Added by Gonetz **
635 0, 0, 0, 0,
636 0, 0, 0, 0,
637 0, 0, 0, 0,
638 0, 0, 0, 0,
639 0, 0, 0, 0,
640 0, 0, 0, 0,
641 0, 0, 0, 0,
642 0, 0, 0, 0,
643 0, 0, 0, 0,
644 0, 0, 0, 0,
645 0, 0, 0, 0,
646 0, 0, 0, 0,
647 0, 0, 0, 0,
648 0, 0, 0, 0,
649 0, 0, 0, 0,
650 0, 0, 0, 0,
651 // 40-7f: unused
652 0, 0, 0, 0,
653 0, 0, 0, 0,
654 0, 0, 0, 0,
655 0, 0, 0, 0,
656 0, 0, 0, 0,
657 0, 0, 0, 0,
658 0, 0, 0, 0,
659 0, 0, 0, 0,
660 0, 0, 0, 0,
661 0, 0, 0, 0,
662 0, 0, 0, 0,
663 0, 0, 0, 0,
664 0, 0, 0, 0,
665 0, 0, 0, 0,
666 0, 0, 0, 0,
667 0, 0, 0, 0,
668 // 80-bf: Immediate commands
669 0, 0, 0, 0,
670 0, 0, 0, 0,
671 0, 0, 0, 0,
672 0, 0, 0, 0,
673 0, 0, 0, 0,
674 0, 0, 0, 0,
675 0, 0, 0, 0,
676 0, 0, 0, 0,
677 0, 0, 0, 0,
678 0, 0, 0, 0,
679 0, 0, 0, 0,
680 0, 0, 0, 0,
681 0, 0, 0, 0,
682 0, 0, 0, 0,
683 uc0_enddl, 0, 0, 0,
684 fb_uc0_moveword, 0, uc0_culldl, 0,
685 // c0-ff: RDP commands
686 0, 0, 0, 0,
687 0, 0, 0, 0,
688 0, 0, 0, 0,
689 0, 0, 0, 0,
690 0, 0, 0, 0,
691 0, 0, 0, 0,
692 0, 0, 0, 0,
693 0, 0, 0, 0,
694 0, 0, 0, 0,
695 fb_rect, fb_rect, 0, 0,
696 0, 0, 0, 0,
697 0, fb_setscissor, 0, 0,
698 0, 0, 0, 0,
699 0, 0, fb_rect, 0,
700 0, 0, 0, 0,
701 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
705 // uCode 4 - RSP SW 2.0D EXT
706 // 00-3f
707 // games: Star Wars: Shadows of the Empire
708 0, 0, 0, 0,
709 0, 0, uc0_displaylist, 0,
710 0, 0, 0, 0,
711 0, 0, 0, 0,
712 0, 0, 0, 0,
713 0, 0, 0, 0,
714 0, 0, 0, 0,
715 0, 0, 0, 0,
716 0, 0, 0, 0,
717 0, 0, 0, 0,
718 0, 0, 0, 0,
719 0, 0, 0, 0,
720 0, 0, 0, 0,
721 0, 0, 0, 0,
722 0, 0, 0, 0,
723 0, 0, 0, 0,
724 // 40-7f: Unused
725 0, 0, 0, 0,
726 0, 0, 0, 0,
727 0, 0, 0, 0,
728 0, 0, 0, 0,
729 0, 0, 0, 0,
730 0, 0, 0, 0,
731 0, 0, 0, 0,
732 0, 0, 0, 0,
733 0, 0, 0, 0,
734 0, 0, 0, 0,
735 0, 0, 0, 0,
736 0, 0, 0, 0,
737 0, 0, 0, 0,
738 0, 0, 0, 0,
739 0, 0, 0, 0,
740 0, 0, 0, 0,
741 // 80-bf: Immediate commands
742 0, 0, 0, 0,
743 0, 0, 0, 0,
744 0, 0, 0, 0,
745 0, 0, 0, 0,
746 0, 0, 0, 0,
747 0, 0, 0, 0,
748 0, 0, 0, 0,
749 0, 0, 0, 0,
750 0, 0, 0, 0,
751 0, 0, 0, 0,
752 0, 0, 0, 0,
753 0, 0, 0, 0,
754 0, 0, 0, 0,
755 0, 0, 0, 0,
756 uc0_enddl, 0, 0, 0,
757 fb_uc0_moveword, 0, uc0_culldl, 0,
758 // c0-ff: RDP commands
759 rdp_noop, 0, 0, 0,
760 0, 0, 0, 0,
761 0, 0, 0, 0,
762 0, 0, 0, 0,
763 0, 0, 0, 0,
764 0, 0, 0, 0,
765 0, 0, 0, 0,
766 0, 0, 0, 0,
767 0, 0, 0, 0,
768 fb_rect, fb_rect, 0, 0,
769 0, 0, 0, 0,
770 0, fb_setscissor, 0, 0,
771 0, 0, 0, 0,
772 0, 0, fb_rect, 0,
773 0, 0, 0, 0,
774 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
778 // uCode 5 - RSP SW 2.0 Diddy
779 // 00-3f
780 // games: Diddy Kong Racing
781 0, 0, 0, 0,
782 0, 0, uc0_displaylist, uc5_dl_in_mem,
783 0, 0, 0, 0,
784 0, 0, 0, 0,
785 0, 0, 0, 0,
786 0, 0, 0, 0,
787 0, 0, 0, 0,
788 0, 0, 0, 0,
789 0, 0, 0, 0,
790 0, 0, 0, 0,
791 0, 0, 0, 0,
792 0, 0, 0, 0,
793 0, 0, 0, 0,
794 0, 0, 0, 0,
795 0, 0, 0, 0,
796 0, 0, 0, 0,
797 // 40-7f: Unused
798 0, 0, 0, 0,
799 0, 0, 0, 0,
800 0, 0, 0, 0,
801 0, 0, 0, 0,
802 0, 0, 0, 0,
803 0, 0, 0, 0,
804 0, 0, 0, 0,
805 0, 0, 0, 0,
806 0, 0, 0, 0,
807 0, 0, 0, 0,
808 0, 0, 0, 0,
809 0, 0, 0, 0,
810 0, 0, 0, 0,
811 0, 0, 0, 0,
812 0, 0, 0, 0,
813 0, 0, 0, 0,
814 // 80-bf: Immediate commands
815 0, 0, 0, 0,
816 0, 0, 0, 0,
817 0, 0, 0, 0,
818 0, 0, 0, 0,
819 0, 0, 0, 0,
820 0, 0, 0, 0,
821 0, 0, 0, 0,
822 0, 0, 0, 0,
823 0, 0, 0, 0,
824 0, 0, 0, 0,
825 0, 0, 0, 0,
826 0, 0, 0, 0,
827 0, 0, 0, 0,
828 0, 0, 0, 0,
829 uc0_enddl, 0, 0, 0,
830 fb_uc0_moveword, 0, uc0_culldl, 0,
831 // c0-ff: RDP commands
832 0, 0, 0, 0,
833 0, 0, 0, 0,
834 0, 0, 0, 0,
835 0, 0, 0, 0,
836 0, 0, 0, 0,
837 0, 0, 0, 0,
838 0, 0, 0, 0,
839 0, 0, 0, 0,
840 0, 0, 0, 0,
841 fb_rect, fb_rect, 0, 0,
842 0, 0, 0, 0,
843 0, fb_setscissor, 0, 0,
844 0, 0, 0, 0,
845 0, 0, fb_rect, 0,
846 0, 0, 0, 0,
847 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
850 // uCode 6 - S2DEX 1.XX
851 // games: Yoshi's Story
853 0, 0, 0, 0,
854 0, 0, uc0_displaylist, 0,
855 0, 0, 0, 0,
856 0, 0, 0, 0,
857 0, 0, 0, 0,
858 0, 0, 0, 0,
859 0, 0, 0, 0,
860 0, 0, 0, 0,
861 0, 0, 0, 0,
862 0, 0, 0, 0,
863 0, 0, 0, 0,
864 0, 0, 0, 0,
865 0, 0, 0, 0,
866 0, 0, 0, 0,
867 0, 0, 0, 0,
868 0, 0, 0, 0,
869 // 40-7f: unused
870 0, 0, 0, 0,
871 0, 0, 0, 0,
872 0, 0, 0, 0,
873 0, 0, 0, 0,
874 0, 0, 0, 0,
875 0, 0, 0, 0,
876 0, 0, 0, 0,
877 0, 0, 0, 0,
878 0, 0, 0, 0,
879 0, 0, 0, 0,
880 0, 0, 0, 0,
881 0, 0, 0, 0,
882 0, 0, 0, 0,
883 0, 0, 0, 0,
884 0, 0, 0, 0,
885 0, 0, 0, 0,
886 // 80-bf: Immediate commands
887 0, 0, 0, 0,
888 0, 0, 0, 0,
889 0, 0, 0, 0,
890 0, 0, 0, 0,
891 0, 0, 0, 0,
892 0, 0, 0, 0,
893 0, 0, 0, 0,
894 0, 0, 0, 0,
895 0, 0, 0, 0,
896 0, 0, 0, 0,
897 0, 0, 0, 0,
898 0, 0, 0, uc6_loaducode,
899 uc6_select_dl, 0, 0, 0,
900 0, 0, 0, 0,
901 uc0_enddl, 0, 0, 0,
902 fb_uc0_moveword, 0, uc2_culldl, 0,
903 // c0-ff: RDP commands
904 0, fb_loadtxtr, fb_loadtxtr, fb_loadtxtr,
905 fb_loadtxtr, 0, 0, 0,
906 0, 0, 0, 0,
907 0, 0, 0, 0,
908 0, 0, 0, 0,
909 0, 0, 0, 0,
910 0, 0, 0, 0,
911 0, 0, 0, 0,
912 0, 0, 0, 0,
913 fb_rect, fb_rect, 0, 0,
914 0, 0, 0, 0,
915 0, fb_setscissor, 0, 0,
916 0, 0, 0, 0,
917 0, 0, fb_rect, 0,
918 0, 0, 0, 0,
919 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
923 0, 0, 0, 0,
924 0, 0, uc0_displaylist, 0,
925 0, 0, 0, 0,
926 0, 0, 0, 0,
927 0, 0, 0, 0,
928 0, 0, 0, 0,
929 0, 0, 0, 0,
930 0, 0, 0, 0,
931 0, 0, 0, 0,
932 0, 0, 0, 0,
933 0, 0, 0, 0,
934 0, 0, 0, 0,
935 0, 0, 0, 0,
936 0, 0, 0, 0,
937 0, 0, 0, 0,
938 0, 0, 0, 0,
939 // 40-7f: unused
940 0, 0, 0, 0,
941 0, 0, 0, 0,
942 0, 0, 0, 0,
943 0, 0, 0, 0,
944 0, 0, 0, 0,
945 0, 0, 0, 0,
946 0, 0, 0, 0,
947 0, 0, 0, 0,
948 0, 0, 0, 0,
949 0, 0, 0, 0,
950 0, 0, 0, 0,
951 0, 0, 0, 0,
952 0, 0, 0, 0,
953 0, 0, 0, 0,
954 0, 0, 0, 0,
955 0, 0, 0, 0,
956 // 80-bf: Immediate commands
957 0, 0, 0, 0,
958 0, 0, 0, 0,
959 0, 0, 0, 0,
960 0, 0, 0, 0,
961 0, 0, 0, 0,
962 0, 0, 0, 0,
963 0, 0, 0, 0,
964 0, 0, 0, 0,
965 0, 0, 0, 0,
966 0, 0, 0, 0,
967 0, 0, 0, 0,
968 0, 0, 0, 0,
969 0, 0, 0, 0,
970 0, 0, 0, 0,
971 uc0_enddl, 0, 0, 0,
972 fb_uc0_moveword, 0, uc0_culldl, 0,
973 // c0-ff: RDP commands
974 0, 0, 0, 0,
975 0, 0, 0, 0,
976 0, 0, 0, 0,
977 0, 0, 0, 0,
978 0, 0, 0, 0,
979 0, 0, 0, 0,
980 0, 0, 0, 0,
981 0, 0, 0, 0,
982 0, 0, 0, 0,
983 fb_rect, fb_rect, 0, 0,
984 0, 0, 0, 0,
985 0, fb_setscissor, 0, 0,
986 0, 0, 0, 0,
987 0, 0, fb_rect, 0,
988 0, 0, 0, 0,
989 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage
993 // 00-3f
994 0, 0, 0, uc2_culldl,
995 uc1_branch_z, 0, 0, 0,
996 0, fb_bg_copy, fb_bg_copy, 0,
997 0, 0, 0, 0,
998 0, 0, 0, 0,
999 0, 0, 0, 0,
1000 0, 0, 0, 0,
1001 0, 0, 0, 0,
1002 0, 0, 0, 0,
1003 0, 0, 0, 0,
1004 0, 0, 0, 0,
1005 0, 0, 0, 0,
1006 0, 0, 0, 0,
1007 0, 0, 0, 0,
1008 0, 0, 0, 0,
1009 0, 0, 0, 0,
1011 // 40-7f: unused
1012 0, 0, 0, 0,
1013 0, 0, 0, 0,
1014 0, 0, 0, 0,
1015 0, 0, 0, 0,
1016 0, 0, 0, 0,
1017 0, 0, 0, 0,
1018 0, 0, 0, 0,
1019 0, 0, 0, 0,
1020 0, 0, 0, 0,
1021 0, 0, 0, 0,
1022 0, 0, 0, 0,
1023 0, 0, 0, 0,
1024 0, 0, 0, 0,
1025 0, 0, 0, 0,
1026 0, 0, 0, 0,
1027 0, 0, 0, 0,
1029 // 80-bf: unused
1030 0, 0, 0, 0,
1031 0, 0, 0, 0,
1032 0, 0, 0, 0,
1033 0, 0, 0, 0,
1034 0, 0, 0, 0,
1035 0, 0, 0, 0,
1036 0, 0, 0, 0,
1037 0, 0, 0, 0,
1038 0, 0, 0, 0,
1039 0, 0, 0, 0,
1040 0, 0, 0, 0,
1041 0, 0, 0, 0,
1042 0, 0, 0, 0,
1043 0, 0, 0, 0,
1044 0, 0, 0, 0,
1045 0, 0, 0, 0,
1047 // c0-ff: RDP commands mixed with uc2 commands
1048 0, 0, 0, 0,
1049 0, 0, 0, 0,
1050 0, 0, 0, 0,
1051 0, 0, 0, 0,
1052 0, 0, 0, 0,
1053 0, uc2_dlist_cnt, 0, 0,
1054 0, 0, 0, fb_uc2_moveword,
1055 0, uc2_load_ucode, uc0_displaylist, uc0_enddl,
1056 0, uc1_rdphalf_1, 0, 0,
1057 fb_rect, fb_rect, 0, 0,
1058 0, 0, 0, 0,
1059 0, fb_setscissor, 0, 0,
1060 0, 0, 0, 0,
1061 0, 0, fb_rect, 0,
1062 0, 0, 0, 0,
1063 0, fb_settextureimage, fb_setdepthimage, fb_setcolorimage