14 static char *dc_peripherals[] = { "Uses WinCE", "Unknown (0x0000002)",
15 "Unknown (0x0000004)", "Unknown (0x0000008)",
16 "VGA Box", "Unknown (0x0000020)",
17 "Unknown (0x0000040)", "Unknown (0x0000080)",
18 "Other Expansions", "Puru Puru pack",
19 "Mike", "Memory card",
20 "Basic controller", "C button",
21 "D button", "X button",
22 "Y button", "Z button",
23 "Expanded direction buttons",
24 "Analog R trigger", "Analog L trigger",
25 "Analog horizontal", "Analog vertical",
26 "Expanded analog horizontal",
27 "Expanded analog vertical",
28 "Gun", "Keyboard", "Mouse" };
30 static uint32_t compute_crc16( dc_bootstrap_head_t h )
32 /* Note: Algorithm taken from http://mc.pp.se/dc/ip0000.bin.html */
33 uint32_t i, c, n = 0xffff;
34 char *data = h->product_id;
35 for (i = 0; i < 16; i++)
38 for (c = 0; c < 8; c++)
47 void parse_ipbin( char *data )
49 struct dc_bootstrap_head *head;
50 int i, got, periph, crc, hcrc;
54 /* Dump out the bootstrap metadata table */
55 head = (struct dc_bootstrap_head *)data;
56 prot_symbols = ((char *)data) + 0x3700;
57 memcpy( buf, head->product_name, 128 );
58 for( i=127; i>0 && buf[i] == ' '; i-- );
60 periph = strtol( head->peripherals, NULL, 16 );
61 INFO( "Bootstrap loaded, Name: %s Author: %-16.16s",
62 buf, head->vendor_id );
63 sprintf( buf, "%4.4s", head->crc );
64 crc = compute_crc16(head);
65 hcrc = strtol( buf, NULL, 16 );
66 emit( crc == hcrc ? EMIT_INFO : EMIT_WARN, MODULE_ID,
67 " Header CRC: %04X (Computed %04X)", hcrc, crc );
68 INFO( " Boot File: %-16.16s", head->boot_file );
69 INFO( " Product ID: %-10.10s Product Ver: %-6.6s Date: %-8.8s",
70 head->product_id, head->product_ver, head->product_date );
71 INFO( " Disc ID: %-11.11s Regions: %-8.8s Peripherals: %07X",
72 head->gdrom_id, head->regions, periph );
73 strcpy( buf, " Supports: " );
75 for( i=0; i<28; i++ ) {
76 if( periph & (1<<i) ){
77 if( got ) strcat( buf, ", " );
78 strcat( buf, dc_peripherals[i] );
81 if( i == 11 ) i = 23; /* Skip 8-23 */
84 strcpy( buf, " Requires: " );
86 for( i=12; i<24; i++ ) {
87 if( periph & (1<<i) ) {
88 if( got ) strcat( buf, ", " );
89 strcat( buf, dc_peripherals[i] );
95 INFO( " Area protection symbols:", NULL );
97 INFO( " %d: %28.28s", i, &prot_symbols[(i*32)+4] );
.