trunk/src/mame/machine/neocrypt.c
| r23829 | r23830 | |
| 678 | 678 | { |
| 679 | 679 | UINT32 rom32 = rom[i] | rom[i+1]<<8 | rom[i+2]<<16 | rom[i+3]<<24; |
| 680 | 680 | rom32 = BITSWAP32( rom32, 0x09, 0x0d, 0x13, 0x00, 0x17, 0x0f, 0x03, 0x05, 0x04, 0x0c, 0x11, 0x1e, 0x12, 0x15, 0x0b, 0x06, 0x1b, 0x0a, 0x1a, 0x1c, 0x14, 0x02, 0x0e, 0x1d, 0x18, 0x08, 0x01, 0x10, 0x19, 0x1f, 0x07, 0x16 ); |
| 681 | | rom[i] = rom32&0xff; |
| 682 | | rom[i+1] = (rom32>>8)&0xff; |
| 683 | | rom[i+2] = (rom32>>16)&0xff; |
| 684 | | rom[i+3] = (rom32>>24)&0xff; |
| 681 | buf[i] = rom32 & 0xff; |
| 682 | buf[i+1] = (rom32>>8) & 0xff; |
| 683 | buf[i+2] = (rom32>>16) & 0xff; |
| 684 | buf[i+3] = (rom32>>24) & 0xff; |
| 685 | 685 | } |
| 686 | | memcpy( buf, rom, rom_size ); |
| 687 | 686 | for( i = 0; i < rom_size / 4; i++ ) |
| 688 | 687 | { |
| 689 | 688 | ofst = BITSWAP24( (i & 0x1fffff), 0x17, 0x16, 0x15, 0x04, 0x0b, 0x0e, 0x08, 0x0c, 0x10, 0x00, 0x0a, 0x13, 0x03, 0x06, 0x02, 0x07, 0x0d, 0x01, 0x11, 0x09, 0x14, 0x0f, 0x12, 0x05 ); |
| r23829 | r23830 | |
| 724 | 723 | { |
| 725 | 724 | rom[ i ] ^= xorval[ (i % 4) ]; |
| 726 | 725 | } |
| 727 | | for ( i = 0; i < rom_size; i+=4 ) |
| 726 | for ( i = 0; i < rom_size; i +=4 ) |
| 728 | 727 | { |
| 729 | | UINT32 *rom32 = (UINT32*)&rom[ i ]; |
| 730 | | *rom32 = BITSWAP32( *rom32, 0x09, 0x0d, 0x13, 0x00, 0x17, 0x0f, 0x03, 0x05, 0x04, 0x0c, 0x11, 0x1e, 0x12, 0x15, 0x0b, 0x06, 0x1b, 0x0a, 0x1a, 0x1c, 0x14, 0x02, 0x0e, 0x1d, 0x18, 0x08, 0x01, 0x10, 0x19, 0x1f, 0x07, 0x16 ); |
| 728 | UINT32 rom32 = rom[i] | rom[i+1]<<8 | rom[i+2]<<16 | rom[i+3]<<24; |
| 729 | rom32 = BITSWAP32( rom32, 0x09, 0x0d, 0x13, 0x00, 0x17, 0x0f, 0x03, 0x05, 0x04, 0x0c, 0x11, 0x1e, 0x12, 0x15, 0x0b, 0x06, 0x1b, 0x0a, 0x1a, 0x1c, 0x14, 0x02, 0x0e, 0x1d, 0x18, 0x08, 0x01, 0x10, 0x19, 0x1f, 0x07, 0x16 ); |
| 730 | buf[i] = rom32 & 0xff; |
| 731 | buf[i+1] = (rom32>>8) & 0xff; |
| 732 | buf[i+2] = (rom32>>16) & 0xff; |
| 733 | buf[i+3] = (rom32>>24) & 0xff; |
| 731 | 734 | } |
| 732 | | memcpy( buf, rom, rom_size ); |
| 733 | 735 | for ( i = 0; i < rom_size; i+=4 ) |
| 734 | 736 | { |
| 735 | 737 | ofst = BITSWAP24( (i & 0x7fffff), 0x17, 0x15, 0x0a, 0x14, 0x13, 0x16, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 ); |
| r23829 | r23830 | |
| 1522 | 1524 | |
| 1523 | 1525 | |
| 1524 | 1526 | /* only found on kf2k3pcb */ |
| 1525 | | void neogeo_state::kof2003biosdecode() |
| 1527 | void neogeo_state::kf2k3pcb_sp1_decrypt() |
| 1526 | 1528 | { |
| 1527 | | static const UINT8 address[0x80]={ |
| 1528 | | 0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3, |
| 1529 | | 0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3, |
| 1530 | | 0x65,0xea,0x6f,0xe0,0xe1,0x6e,0xeb,0x64, |
| 1531 | | 0x65,0xea,0x6f,0xe0,0xe1,0x6e,0xeb,0x64, |
| 1532 | | 0x45,0xca,0x47,0xc8,0xc9,0x46,0xcb,0x44, |
| 1533 | | 0x45,0xca,0x47,0xc8,0xc9,0x46,0xcb,0x44, |
| 1534 | | 0x9a,0x15,0x98,0x17,0x1e,0x91,0x1c,0x93, |
| 1535 | | 0x9a,0x15,0x98,0x17,0x1e,0x91,0x1c,0x93, |
| 1536 | | 0x7e,0xf1,0x7c,0xf3,0xf0,0x7f,0xf2,0x7d, |
| 1537 | | 0x7e,0xf1,0x7c,0xf3,0xf0,0x7f,0xf2,0x7d, |
| 1538 | | 0x27,0xa8,0x25,0xaa,0xa3,0x2c,0xa1,0x2e, |
| 1539 | | 0x27,0xa8,0x25,0xaa,0xa3,0x2c,0xa1,0x2e, |
| 1540 | | 0x04,0x8b,0x06,0x89,0x80,0x0f,0x82,0x0d, |
| 1541 | | 0x04,0x8b,0x06,0x89,0x80,0x0f,0x82,0x0d, |
| 1542 | | 0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9, |
| 1543 | | 0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9, |
| 1529 | static const UINT8 address[0x40] = { |
| 1530 | 0x04,0x0a,0x04,0x0a,0x04,0x0a,0x04,0x0a, |
| 1531 | 0x0a,0x04,0x0a,0x04,0x0a,0x04,0x0a,0x04, |
| 1532 | 0x09,0x07,0x09,0x07,0x09,0x07,0x09,0x07, |
| 1533 | 0x09,0x09,0x04,0x04,0x09,0x09,0x04,0x04, |
| 1534 | 0x0b,0x0d,0x0b,0x0d,0x03,0x05,0x03,0x05, |
| 1535 | 0x0e,0x0e,0x03,0x03,0x0e,0x0e,0x03,0x03, |
| 1536 | 0x03,0x05,0x0b,0x0d,0x03,0x05,0x0b,0x0d, |
| 1537 | 0x04,0x00,0x04,0x00,0x0e,0x0a,0x0e,0x0a |
| 1544 | 1538 | }; |
| 1545 | | UINT16*src= (UINT16*)memregion( "mainbios" )->base(); |
| 1546 | | UINT16*buf= auto_alloc_array(machine(), UINT16, 0x80000/2); |
| 1547 | | int a,addr; |
| 1548 | 1539 | |
| 1549 | | for (a=0;a<0x80000/2;a++) |
| 1540 | UINT16 *rom = (UINT16 *)memregion("mainbios")->base(); |
| 1541 | UINT16 *buf = auto_alloc_array(machine(), UINT16, 0x80000/2); |
| 1542 | int i, addr; |
| 1543 | |
| 1544 | for (i = 0; i < 0x80000/2; i++) |
| 1550 | 1545 | { |
| 1551 | | if (src[a] & (0x0004 << (8*BYTE_XOR_LE(0)))) src[a] ^= 0x0001 << (8*BYTE_XOR_LE(0)); |
| 1552 | | if (src[a] & (0x0010 << (8*BYTE_XOR_LE(0)))) src[a] ^= 0x0002 << (8*BYTE_XOR_LE(0)); |
| 1553 | | if (src[a] & (0x0020 << (8*BYTE_XOR_LE(0)))) src[a] ^= 0x0008 << (8*BYTE_XOR_LE(0)); |
| 1554 | | //address xor |
| 1555 | | addr = a & ~0xff; |
| 1556 | | addr |= address[BYTE_XOR_LE(a & 0x7f)]; |
| 1557 | | if ( a & 0x00008) addr ^= 0x0008; |
| 1558 | | if ( a & 0x00080) addr ^= 0x0080; |
| 1559 | | if ( a & 0x00200) addr ^= 0x0100; |
| 1560 | | if (~a & 0x02000) addr ^= 0x0400; |
| 1561 | | if (~a & 0x10000) addr ^= 0x1000; |
| 1562 | | if ( a & 0x02000) addr ^= 0x8000; |
| 1563 | | buf[addr]=src[a]; |
| 1546 | // address xor |
| 1547 | addr = i ^ 0x0020; |
| 1548 | if ( i & 0x00020) addr ^= 0x0010; |
| 1549 | if (~i & 0x00010) addr ^= 0x0040; |
| 1550 | if (~i & 0x00004) addr ^= 0x0080; |
| 1551 | if ( i & 0x00200) addr ^= 0x0100; |
| 1552 | if (~i & 0x02000) addr ^= 0x0400; |
| 1553 | if (~i & 0x10000) addr ^= 0x1000; |
| 1554 | if ( i & 0x02000) addr ^= 0x8000; |
| 1555 | addr ^= address[((i >> 1) & 0x38) | (i & 7)]; |
| 1556 | buf[i] = rom[addr]; |
| 1557 | |
| 1558 | // data xor |
| 1559 | if (buf[i] & 0x0004) buf[i] ^= 0x0001; |
| 1560 | if (buf[i] & 0x0010) buf[i] ^= 0x0002; |
| 1561 | if (buf[i] & 0x0020) buf[i] ^= 0x0008; |
| 1564 | 1562 | } |
| 1565 | | memcpy(src,buf,0x80000); |
| 1563 | |
| 1564 | memcpy(rom, buf, 0x80000); |
| 1566 | 1565 | auto_free(machine(), buf); |
| 1566 | |
| 1567 | { |
| 1568 | FILE *fp; |
| 1569 | const char *gamename = machine().system().name; |
| 1570 | int rom_size = memregion("mainbios")->bytes(); |
| 1571 | char filename[256]; |
| 1572 | sprintf(filename, "%s_bios.dump", gamename); |
| 1573 | |
| 1574 | fp=fopen(filename, "w+b"); |
| 1575 | if (fp) |
| 1576 | { |
| 1577 | fwrite(rom, rom_size, 1, fp); |
| 1578 | fclose(fp); |
| 1579 | } |
| 1580 | } |
| 1567 | 1581 | } |