34 SpecialMicrocodeInfo specialMicrocodes[] =
36 {F3DWRUS, FALSE, 0xd17906e2, "RSP SW Version: 2.0D, 04-01-96"},
37 {F3DWRUS, FALSE, 0x94c4c833, "RSP SW Version: 2.0D, 04-01-96"},
38 {S2DEX, FALSE, 0x9df31081, "RSP Gfx ucode S2DEX 1.06 Yoshitaka Yasumoto Nintendo."},
39 {F3DDKR, FALSE, 0x8d91244f, "Diddy Kong Racing"},
40 {F3DDKR, FALSE, 0x6e6fc893, "Diddy Kong Racing"},
41 {F3DDKR, FALSE, 0xbde9d1fb, "Jet Force Gemini"},
42 {F3DPD, FALSE, 0x1c4f7869, "Perfect Dark"},
43 {F3DEX, FALSE, 0x0ace4c3f, "Mario Kart"},
44 //{F3DEX, FALSE, 0xda51ccdb, "Rogue Squadron"},
45 //{F3DCBFD, FALSE, 0x1b4ace88, "RSP Gfx ucode F3DEXBG.NoN fifo 2.08 Yoshitaka Yasumoto 1999 Nintendo."},
48 u32 G_RDPHALF_1, G_RDPHALF_2, G_RDPHALF_CONT;
50 u32 G_SETOTHERMODE_H, G_SETOTHERMODE_L;
51 u32 G_DL, G_ENDDL, G_CULLDL, G_BRANCH_Z;
53 u32 G_MOVEMEM, G_MOVEWORD;
55 u32 G_GEOMETRYMODE, G_SETGEOMETRYMODE, G_CLEARGEOMETRYMODE;
57 u32 G_DMA_IO, G_DMA_DL, G_DMA_TRI, G_DMA_MTX, G_DMA_VTX, G_DMA_OFFSETS;
58 u32 G_SPECIAL_1, G_SPECIAL_2, G_SPECIAL_3;
59 u32 G_VTX, G_MODIFYVTX, G_VTXCOLORBASE;
60 u32 G_TRI1, G_TRI2, G_TRI4;
62 u32 G_RESERVED0, G_RESERVED1, G_RESERVED2, G_RESERVED3;
64 u32 G_BG_1CYC, G_BG_COPY;
65 u32 G_OBJ_RECTANGLE, G_OBJ_SPRITE, G_OBJ_MOVEMEM;
66 u32 G_SELECT_DL, G_OBJ_RENDERMODE, G_OBJ_RECTANGLE_R;
67 u32 G_OBJ_LOADTXTR, G_OBJ_LDTX_SPRITE, G_OBJ_LDTX_RECT, G_OBJ_LDTX_RECT_R;
68 u32 G_RDPHALF_0, G_TRI_UNKNOWN;
87 u32 G_MWO_aLIGHT_1, G_MWO_bLIGHT_1;
88 u32 G_MWO_aLIGHT_2, G_MWO_bLIGHT_2;
89 u32 G_MWO_aLIGHT_3, G_MWO_bLIGHT_3;
90 u32 G_MWO_aLIGHT_4, G_MWO_bLIGHT_4;
91 u32 G_MWO_aLIGHT_5, G_MWO_bLIGHT_5;
92 u32 G_MWO_aLIGHT_6, G_MWO_bLIGHT_6;
93 u32 G_MWO_aLIGHT_7, G_MWO_bLIGHT_7;
94 u32 G_MWO_aLIGHT_8, G_MWO_bLIGHT_8;
96 //GBIFunc GBICmd[256];
99 void GBI_Unknown( u32 w0, u32 w1 )
104 INT_PTR CALLBACK MicrocodeDlgProc( HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
109 for (int i = 0; i < numMicrocodeTypes; i++)
111 SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_ADDSTRING, 0, (LPARAM)MicrocodeTypes[i] );
113 SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_SETCURSEL, 0, 0 );
116 sprintf( text, "Microcode CRC:\t\t0x%08x\r\nMicrocode Data CRC:\t0x%08x\r\nMicrocode Text:\t\t%s", uc_crc, uc_dcrc, uc_str );
117 SendDlgItemMessage( hWndDlg, IDC_TEXTBOX, WM_SETTEXT, NULL, (LPARAM)text );
121 switch (LOWORD(wParam))
124 EndDialog( hWndDlg, SendDlgItemMessage( hWndDlg, IDC_MICROCODE, CB_GETCURSEL, 0, 0 ) );
128 EndDialog( hWndDlg, NONE );
136 #elif defined(USE_GTK)
137 static int selectedMicrocode = -1;
138 static GtkWidget *microcodeWindow = 0;
139 static GtkWidget *microcodeList = 0;
141 static void okButton_clicked( GtkWidget *widget, void *data )
143 gtk_widget_hide( microcodeWindow );
144 if (GTK_LIST(microcodeList)->selection != 0)
147 GtkListItem *item = GTK_LIST_ITEM(GTK_LIST(microcodeList)->selection->data);
148 GtkLabel *label = GTK_LABEL(GTK_BIN(item)->child);
149 gtk_label_get( label, &text );
151 for (int i = 0; i < numMicrocodeTypes; i++)
152 if (!strcmp( text, MicrocodeTypes[i] ))
154 selectedMicrocode = i;
159 selectedMicrocode = NONE;
162 static void stopButton_clicked( GtkWidget *widget, void *data )
164 gtk_widget_hide( microcodeWindow );
165 selectedMicrocode = NONE;
169 delete_question_event(GtkWidget *widget, GdkEvent *event, gpointer data)
171 return TRUE; // undeleteable
174 static int MicrocodeDialog()
176 GtkWidget *infoLabel;
177 GtkWidget *infoFrame, *infoTable;
178 GtkWidget *crcInfoLabel, *crcDataInfoLabel, *textInfoLabel;
179 GtkWidget *crcLabel = NULL, *crcDataLabel = NULL, *textLabel = NULL;
180 GtkWidget *selectUcodeLabel;
181 //GtkWidget *microcodeLabel;
182 GtkWidget *okButton, *stopButton;
183 GList *ucodeList = 0;
186 if (!g_thread_supported())
187 g_thread_init( NULL );
191 if (microcodeWindow == 0)
193 microcodeWindow = gtk_dialog_new();
194 gtk_signal_connect( GTK_OBJECT(microcodeWindow), "delete_event",
195 GTK_SIGNAL_FUNC(delete_question_event), (gpointer)NULL );
196 sprintf( buf, "%s - unknown microcode", pluginName );
197 gtk_window_set_title( GTK_WINDOW(microcodeWindow), buf );
198 gtk_container_set_border_width( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->vbox), 11 );
201 okButton = gtk_button_new_with_label( "Ok" );
202 gtk_signal_connect_object( GTK_OBJECT(okButton), "clicked",
203 GTK_SIGNAL_FUNC(okButton_clicked), NULL );
204 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), okButton );
207 stopButton = gtk_button_new_with_label( "Stop" );
208 gtk_signal_connect_object( GTK_OBJECT(stopButton), "clicked",
209 GTK_SIGNAL_FUNC(stopButton_clicked), NULL );
210 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(microcodeWindow)->action_area), stopButton );
213 infoLabel = gtk_label_new( "Unknown microcode. Please notify Orkin, including the following information:" );
214 gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoLabel );
217 infoFrame = gtk_frame_new( "Microcode info" );
218 gtk_container_set_border_width( GTK_CONTAINER(infoFrame), 7 );
219 gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), infoFrame );
221 infoTable = gtk_table_new( 3, 2, FALSE );
222 gtk_container_set_border_width( GTK_CONTAINER(infoTable), 7 );
223 gtk_table_set_col_spacings( GTK_TABLE(infoTable), 3 );
224 gtk_table_set_row_spacings( GTK_TABLE(infoTable), 3 );
225 gtk_container_add( GTK_CONTAINER(infoFrame), infoTable );
227 crcInfoLabel = gtk_label_new( "Microcode CRC:" );
228 crcDataInfoLabel = gtk_label_new( "Microcode Data CRC:" );
229 textInfoLabel = gtk_label_new( "Microcode Text:" );
231 crcLabel = gtk_label_new( "" );
232 crcDataLabel = gtk_label_new( "" );
233 textLabel = gtk_label_new( "" );
235 gtk_table_attach_defaults( GTK_TABLE(infoTable), crcInfoLabel, 0, 1, 0, 1 );
236 gtk_table_attach_defaults( GTK_TABLE(infoTable), crcLabel, 1, 2, 0, 1 );
237 gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataInfoLabel, 0, 1, 1, 2 );
238 gtk_table_attach_defaults( GTK_TABLE(infoTable), crcDataLabel, 1, 2, 1, 2 );
239 gtk_table_attach_defaults( GTK_TABLE(infoTable), textInfoLabel, 0, 1, 2, 3 );
240 gtk_table_attach_defaults( GTK_TABLE(infoTable), textLabel, 1, 2, 2, 3 );
242 selectUcodeLabel = gtk_label_new( "You can manually select the closest matching microcode." );
243 for (int i = 0; i < numMicrocodeTypes; i++)
244 ucodeList = g_list_append( ucodeList, gtk_list_item_new_with_label( MicrocodeTypes[i] ) );
245 microcodeList = gtk_list_new();
246 gtk_list_set_selection_mode( GTK_LIST(microcodeList), GTK_SELECTION_SINGLE );
247 gtk_list_append_items( GTK_LIST(microcodeList), ucodeList );
249 gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), selectUcodeLabel );
250 gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(microcodeWindow)->vbox), microcodeList );
253 snprintf( buf, 1024, "0x%8.8X", (unsigned int)uc_crc );
254 if(crcLabel) gtk_label_set_text( GTK_LABEL(crcLabel), buf );
255 snprintf( buf, 1024, "0x%8.8X", (unsigned int)uc_dcrc );
256 if(crcDataLabel) gtk_label_set_text( GTK_LABEL(crcDataLabel), buf );
257 if(textLabel) gtk_label_set_text( GTK_LABEL(textLabel), uc_str );
259 selectedMicrocode = -1;
260 gtk_widget_show_all( microcodeWindow );
262 while (selectedMicrocode == -1)
264 if( gtk_main_iteration() )
270 return selectedMicrocode;
273 static int MicrocodeDialog()
280 MicrocodeInfo *GBI_AddMicrocode()
282 MicrocodeInfo *newtop = (MicrocodeInfo*)malloc( sizeof( MicrocodeInfo ) );
284 newtop->lower = GBI.top;
285 newtop->higher = NULL;
288 GBI.top->higher = newtop;
306 GBI.numMicrocodes = 0;
308 for (u32 i = 0; i <= 0xFF; i++)
309 GBI.cmd[i] = GBI_Unknown;
320 MicrocodeInfo *newBottom = GBI.bottom->higher;
322 if (GBI.bottom == GBI.top)
327 GBI.bottom = newBottom;
330 GBI.bottom->lower = NULL;
337 void GBI_ProfileInit()
342 void GBI_ProfileBegin(u32 cmd)
344 GBI.profileTmp = ticksGetTicks();
347 void GBI_ProfileEnd(u32 cmd)
349 unsigned int i = 256*GBI.current->type + cmd;
351 GBI.profileTimer[i] += ticksGetTicks() - GBI.profileTmp;
357 memset(GBI.profileTimer, 0, 12 * 256 * sizeof(int));
358 memset(GBI.profileNum, 0, 12 * 256 * sizeof(int));
362 GBI_GetFuncTime(u32 ucode, u32 cmd)
364 return GBI.profileTimer[ucode*256+cmd];
368 GBI_GetFuncNum(u32 ucode, u32 cmd)
370 return GBI.profileNum[ucode*256+cmd];
374 GBI_ProfilePrint(FILE *file)
376 int uc, cmd, total=0;
380 for(cmd=0;cmd<256;cmd++)
382 total += GBI_GetFuncTime(uc, cmd);
389 for(cmd=0;cmd<256;cmd++)
391 unsigned int t = GBI_GetFuncTime(uc, cmd);
394 fprintf(file, "%s x %i = %u ms (%.2f%%)\n", GBI_GetFuncName(uc,cmd), GBI_GetFuncNum(uc, cmd), t, 100.0f * (float)t / total);
402 GBI_GetUcodeName(u32 ucode)
406 case F3D: return "F3D";
407 case F3DEX: return "F3DEX";
408 case F3DEX2: return "F3DEX2";
409 case L3D: return "L3D";
410 case L3DEX: return "L3DEX";
411 case L3DEX2: return "L3DEX2";
412 case S2DEX: return "S2DEX";
413 case S2DEX2: return "S2DEX2";
414 case F3DPD: return "F3DPD";
415 case F3DDKR: return "F3DDKR";
416 case F3DWRUS: return "F3DWRUS";
417 case NONE: return "NONE";
418 default: return "UNKNOWN UCODE";
423 GBI_GetFuncName(unsigned int ucode, unsigned int cmd)
428 case G_SETCIMG: return "G_SETCIMG";
429 case G_SETZIMG: return "G_SETZIMG";
430 case G_SETTIMG: return "G_SETTIMG";
431 case G_SETCOMBINE: return "G_SETCOMBINE";
432 case G_SETENVCOLOR: return "G_SETENVCOLOR";
433 case G_SETPRIMCOLOR: return "G_SETPRIMCOLOR";
434 case G_SETBLENDCOLOR: return "G_SETBLENDCOLOR";
435 case G_SETFOGCOLOR: return "G_SETFOGCOLOR";
436 case G_SETFILLCOLOR: return "G_SETFILLCOLOR";
437 case G_FILLRECT: return "G_FILLRECT";
438 case G_SETTILE: return "G_SETTILE";
439 case G_LOADTILE: return "G_LOADTILE";
440 case G_LOADBLOCK: return "G_LOADBLOCK";
441 case G_SETTILESIZE: return "G_SETTILESIZE";
442 case G_LOADTLUT: return "G_LOADTLUT";
443 case G_RDPSETOTHERMODE: return "G_RDPSETOTHERMODE";
444 case G_SETPRIMDEPTH: return "G_SETPRIMDEPTH";
445 case G_SETSCISSOR: return "G_SETSCISSOR";
446 case G_SETCONVERT: return "G_SETCONVERT";
447 case G_SETKEYR: return "G_SETKEYR";
448 case G_SETKEYGB: return "G_SETKEYGB";
449 case G_RDPFULLSYNC: return "G_RDPFULLSYNC";
450 case G_RDPTILESYNC: return "G_RDPTILESYNC";
451 case G_RDPPIPESYNC: return "G_RDPPIPESYNC";
452 case G_RDPLOADSYNC: return "G_RDPLOADSYNC";
453 case G_TEXRECTFLIP: return "G_TEXRECTFLIP";
456 case 0x00: return "SPNOOP";
463 S2DEX2_OBJ_RECTANGLE 0x01
469 case F3DEX2: return "F3DEX2_VTX";
470 case F3DDKR: return "F3DDKR_DMA_MTX";
471 case S2DEX: return "S2DEX_BG_1CYC";
472 case S2DEX2: return "S2DEX2_OBJ_RECTANGLE";
473 default: return "F3D_MTX";
478 F3DEX2_MODIFYVTX 0x02
480 S2DEX2_OBJ_SPRITE 0x02
486 case F3DEX2: return "F3DEX2_MODIFYVTX";
487 case S2DEX: return "S2DEX_BG_COPY";
488 case S2DEX2: return "S2DEX2_OBJ_SPRITE";
489 default: return "F3D_RESERVED0";
495 S2DEX_OBJ_RECTANGLE 0x03
501 case F3DEX2: return "F3DEX2_CULLDL";
502 case S2DEX: return "S2DEX_OBJ_RECTANGLE";
503 default: return "F3D_MOVEMEM";
510 S2DEX_OBJ_SPRITE 0x04
511 S2DEX2_SELECT_DL 0x04
517 case F3DEX2: return "F3DEX2_BRANCH_Z";
518 case F3DDKR: return "F3DDKR_DMA_VTX";
519 case S2DEX: return "S2DEX_OBJ_SPRITE";
520 case S2DEX2: return "S2DEX2_SELECT_DL";
521 default: return "F3D_VTX";
529 S2DEX_OBJ_MOVEMEM 0x05
530 S2DEX2_OBJ_LOADTXTR 0x05
536 case F3DEX2: return "F3DEX2_TR1";
537 case F3DDKR: return "F3DDKR_DMA_TRI";
538 case S2DEX: return "S2DEX_OBJ_MOVEMEM";
539 case S2DEX2: return "S2DEX2_OBJ_LOADTXTR";
540 default: return "F3D_RESERVED1";
546 S2DEX2_OBJ_LDTX_SPRITE 0x06
552 case F3DEX2: return "F3DEX2_TR2";
553 case S2DEX2: return "S2DEX2_OBJ_LDTX_SPRITE";
554 default: return "F3D_DL";
561 F3DPD_VTXCOLORBASE 0x07
563 S2DEX2_OBJ_LDTX_RECT 0x07
569 case F3DEX2: return "F3DEX2_QUAD";
570 case F3DPD: return "F3DPD_VTXCOLORBASE";
571 case F3DDKR: return "F3DDKR_DMA_DL";
572 case S2DEX2: return "S2DEX2_OBJ_LDTX_RECT";
573 default: return "F3D_RESERVED2";
579 S2DEX2_OBJ_LDTX_RECT_R 0x08
585 case L3DEX2: return "L3DEX2_LINE3D";
586 case S2DEX2: return "S2DEX2_OBJ_LDTX_RECT_R";
587 default: return "F3D_RESERVED3";
592 F3D_SPRITE2D_BASE: 0x09
599 case S2DEX2: return "S2DEX2_BG_1CYC";
600 default: return "F3D_SPRITE2D_BASE";
604 // S2DEX2_BG_COPY 0x0A
605 case 0x0A: return "S2DEX2_BG_COPY";
606 // S2DEX2_OBJ_RENDERMODE 0x0B
607 case 0x0B: return "S2DEX2_OBJ_RENDERMODE";
608 // F3DEX2_RDPHALF_2 0xF1
609 case 0xF1: return "F3DEX2_RDPHALF_2";
612 S2DEX2_RDPHALF_0 0xE4
618 case S2DEX: return "S2DEX_RDPHALF_0";
619 case S2DEX2: return "S2DEX2_RDPHALF_0";
620 default: return "G_TEXRECT";
623 // F3DEX2_SETOTHERMODE_H 0xE3
624 case 0xE3: return "F3DEX2_SETOTHERMODE_H";
625 // F3DEX2_SETOTHERMODE_L 0xE2
626 case 0xE2: return "F3DEX2_SETOTHERMODE_L";
627 // F3DEX2_RDPHALF_1 0xE1
628 case 0xE1: return "F3DEX2_RDPHALF_1";
629 // F3DEX2_SPNOOP 0xE0
630 case 0xE0: return "F3DEX2_SPNOOP";
632 case 0xDF: return "F3DEX2_ENDDL";
634 case 0xDE: return "F3DEX2_DL";
635 // F3DEX2_LOAD_UCODE 0xDD
636 case 0xDD: return "F3DEX2_LOAD_UCODE";
639 S2DEX2_OBJ_MOVEMEM 0xDC
645 case S2DEX2: return "S2DEX2_OBJ_MOVEMEM";
646 default: return "F3DEX2_MOVEMEM";
649 // F3DEX2_MOVEWORD 0xDB
650 case 0xDB: return "F3DEX2_MOVEWORD";
653 S2DEX2_OBJ_RECTANGLE_R 0xDA
659 case S2DEX2: return "S2DEX2_OBJ_RECTANGLE_R";
660 default: return "F3DEX2_MTX";
663 // F3DEX2_GEOMETRYMODE 0xD9
664 case 0xD9: return "F3DEX2_GEOMETRYMODE";
665 // F3DEX2_POPMTX 0xD8
666 case 0xD8: return "F3DEX2_POPMTX";
667 // F3DEX2_TEXTURE 0xD7
668 case 0xD7: return "F3DEX2_TEXTURE";
669 // F3DEX2_DMA_IO 0xD6
670 case 0xD6: return "F3DEX2_DMA_IO";
671 // F3DEX2_SPECIAL_1 0xD5
672 case 0xD5: return "F3DEX2_SPECIAL_1";
673 // F3DEX2_SPECIAL_2 0xD4
674 case 0xD4: return "F3DEX2_SPECIAL_2";
675 // F3DEX2_SPECIAL_3 0xD3
676 case 0xD3: return "F3DEX2_SPECIAL_3";
678 // S2DEX_OBJ_LOADTXTR 0xC1
679 case 0xC1: return "S2DEX_OBJ_LOADTXTR";
680 // S2DEX_OBJ_LDTX_SPRITE 0xC2
681 case 0xC2: return "S2DEX_OBJ_LDTX_SPRITE";
682 // S2DEX_OBJ_LDTX_RECT 0xC3
683 case 0xC3: return "S2DEX_OBJ_LDTX_RECT";
684 // S2DEX_OBJ_LDTX_RECT_R 0xC4
685 case 0xC4: return "S2DEX_OBJ_LDTX_RECT_R";
688 F3DDKR_DMA_OFFSETS 0xBF
694 case F3DDKR: return "F3DDKR_DMA_OFFSETS";
695 default: return "F3D_TRI1";
700 case 0xBE: return "F3D_CULLDL";
702 case 0xBD: return "F3D_POPMTX";
703 // F3D_MOVEWORD: 0xBC
704 case 0xBC: return "F3D_MOVEWORD";
706 case 0xBB: return "F3D_TEXTURE";
707 // F3D_SETOTHERMODE_H: 0xBA
708 case 0xBA: return "F3D_SETOTHERMODE_H";
709 // F3D_SETOTHERMODE_L: 0xB9
710 case 0xB9: return "F3D_SETOTHERMODE_L";
712 case 0xB8: return "F3D_ENDDL";
713 // F3D_SETGEOMETRYMODE: 0xB7
714 case 0xB7: return "F3D_SETGEOMETRYMODE";
715 // F3D_CLEARGEOMETRYMODE: 0xB6
716 case 0xB6: return "F3D_CLEARGEOMETRYMODE";
725 case L3D: return "L3D_LINE3D";
726 default: return "F3D_QUAD";
730 // F3D_RDPHALF_1: 0xB4
731 case 0xB4: return "F3D_RDPHALF_1";
732 // F3D_RDPHALF_2: 0xB3
733 case 0xB3: return "F3D_RDPHALF_2";
735 F3D_RDPHALF_CONT: 0xB2
737 S2DEX_OBJ_RECTANGLE_R 0xB2
743 case F3DEX: return "F3DEX_MODIFYVTX";
744 case S2DEX: return "S2DEX_OBJ_RECTANGLE_R";
745 default: return "F3D_RDPHALF_CONT";
752 S2DEX_OBJ_RENDERMODE 0xB1
758 case F3DEX: return "F3DEX_TRI2";
759 case F3DWRUS: return "F3DWRUS_TRI2";
760 case S2DEX: return "S2DEX_OBJ_RENDERMODE";
761 default: return "F3D_TRI4";
772 case S2DEX: return "S2DEX_SELECT_DL";
773 default: return "F3DEX_BRANCH_Z";
777 F3DEX_LOAD_UCODE 0xAF
778 S2DEX_LOAD_UCODE 0xAF
784 case S2DEX: return "S2DEX_LOAD_UCODE";
785 default: return "F3DEX_LOAD_UCODE";
791 if (ucode == F3DCBFD)
793 if (cmd >= 0x10 && cmd <= 0x1f)
794 return "F3DCBFD_TRI4";
797 return "UNKNOWN CMD";
803 MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
805 MicrocodeInfo *current;
807 for (unsigned int i = 0; i < GBI.numMicrocodes; i++)
813 if ((current->address == uc_start) && (current->dataAddress == uc_dstart) && (current->dataSize == uc_dsize))
816 current = current->lower;
820 current = GBI_AddMicrocode();
822 current->address = uc_start;
823 current->dataAddress = uc_dstart;
824 current->dataSize = uc_dsize;
825 current->NoN = FALSE;
826 current->type = NONE;
828 // See if we can identify it by CRC
829 uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096);
830 LOG(LOG_MINIMAL, "UCODE CRC=0x%x\n", uc_crc);
832 for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
834 if (uc_crc == specialMicrocodes[i].crc)
836 current->type = specialMicrocodes[i].type;
841 // See if we can identify it by text
843 UnswapCopy( &RDRAM[uc_dstart & 0x1FFFFFFF], uc_data, 2048 );
844 strcpy( uc_str, "Not Found" );
846 for (u32 i = 0; i < 2048; i++)
848 if ((uc_data[i] == 'R') && (uc_data[i+1] == 'S') && (uc_data[i+2] == 'P'))
851 while (uc_data[i+j] > 0x0A)
853 uc_str[j] = uc_data[i+j];
861 if (strncmp( &uc_str[4], "SW", 2 ) == 0)
865 else if (strncmp( &uc_str[4], "Gfx", 3 ) == 0)
867 current->NoN = (strncmp( &uc_str[20], ".NoN", 4 ) == 0);
869 if (strncmp( &uc_str[14], "F3D", 3 ) == 0)
871 if (uc_str[28] == '1')
873 else if (uc_str[31] == '2')
876 else if (strncmp( &uc_str[14], "L3D", 3 ) == 0)
878 if (uc_str[28] == '1')
880 else if (uc_str[31] == '2')
883 else if (strncmp( &uc_str[14], "S2D", 3 ) == 0)
885 if (uc_str[28] == '1')
887 else if (uc_str[31] == '2')
892 LOG(LOG_VERBOSE, "UCODE STRING=%s\n", uc_str);
896 current->type = type;
905 for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
907 if (strcmp( uc_str, specialMicrocodes[i].text ) == 0)
909 current->type = specialMicrocodes[i].type;
914 // Let the user choose the microcode
915 LOG(LOG_ERROR, "[gles2n64]: Warning - unknown ucode!!!\n");
916 if(last_good_ucode != (u32)-1)
918 current->type=last_good_ucode;
922 current->type = MicrocodeDialog();
927 void GBI_MakeCurrent( MicrocodeInfo *current )
929 if (current != GBI.top)
931 if (current == GBI.bottom)
933 GBI.bottom = current->higher;
934 GBI.bottom->lower = NULL;
938 current->higher->lower = current->lower;
939 current->lower->higher = current->higher;
942 current->higher = NULL;
943 current->lower = GBI.top;
944 GBI.top->higher = current;
948 if (!GBI.current || (GBI.current->type != current->type))
951 for (int i = 0; i <= 0xFF; i++)
952 GBI.cmd[i] = GBI_Unknown;
955 switch (current->type)
957 case F3D: F3D_Init(); break;
958 case F3DEX: F3DEX_Init(); break;
959 case F3DEX2: F3DEX2_Init(); break;
960 case L3D: L3D_Init(); break;
961 case L3DEX: L3DEX_Init(); break;
962 case L3DEX2: L3DEX2_Init(); break;
963 case S2DEX: S2DEX_Init(); break;
964 case S2DEX2: S2DEX2_Init(); break;
965 case F3DDKR: F3DDKR_Init(); break;
966 case F3DWRUS: F3DWRUS_Init(); break;
967 case F3DPD: F3DPD_Init(); break;
968 case F3DCBFD: F3DCBFD_Init(); break;
973 GBI.current = current;