trunk/src/mame/machine/pgmprot_igs027a_type1.c
| r24663 | r24664 | |
| 564 | 564 | |
| 565 | 565 | /* preliminary */ |
| 566 | 566 | |
| 567 | // not accurate, low bits (0x03 mask) are certainly wrong, possibly others |
| 568 | UINT8 puzzli2_level_decode[256] = { |
| 569 | 0x32, 0x3e, 0xb2, 0x37, 0x31, 0x22, 0xd6, 0x0d, 0x35, 0x5c, 0x8d, 0x3c, 0x7a, 0x5f, 0xd4, 0xad, |
| 570 | 0x53, 0xff, 0xe9, 0x45, 0xed, 0x11, 0x68, 0x77, 0xd8, 0x34, 0x36, 0x45, 0xa6, 0xeb, 0x1c, 0xc7, |
| 571 | 0x3b, 0xbd, 0xad, 0x2f, 0x18, 0xde, 0xa1, 0xaa, 0xdd, 0x50, 0x57, 0xc2, 0xe5, 0x0a, 0x01, 0x6d, |
| 572 | 0x67, 0x65, 0x14, 0x70, 0xb7, 0x39, 0x24, 0x79, 0x83, 0xd2, 0x71, 0xb9, 0x10, 0xf5, 0x92, 0x93, |
| 573 | 0xfa, 0xe4, 0x5e, 0xb0, 0xf6, 0xaf, 0x95, 0x8a, 0x7d, 0x73, 0xf9, 0x63, 0x86, 0xcb, 0x1a, 0x56, |
| 574 | 0xf1, 0x3a, 0xae, 0x63, 0x01, 0x29, 0x96, 0x22, 0x8f, 0x5d, 0x9a, 0x65, 0x74, 0x21, 0x20, 0x40, |
| 575 | 0xd3, 0x05, 0xa2, 0xe3, 0xbc, 0x9e, 0x1e, 0x10, 0x15, 0x0c, 0x8a, 0x9c, 0xec, 0x38, 0xb6, 0x9d, |
| 576 | 0x2a, 0xf7, 0x14, 0x0e, 0x85, 0xc7, 0x7f, 0xce, 0x94, 0x16, 0x48, 0xa9, 0x80, 0x6e, 0x78, 0xd8, |
| 577 | 0xa6, 0x7e, 0x42, 0xe4, 0xa2, 0x2b, 0xef, 0xed, 0x24, 0xba, 0xb8, 0x7e, 0xc9, 0x2b, 0x90, 0xcc, |
| 578 | 0x58, 0xd1, 0xf3, 0xe2, 0x6f, 0xed, 0x9f, 0xf0, 0x4a, 0x54, 0x8d, 0x08, 0xf8, 0x51, 0x68, 0xc8, |
| 579 | 0x03, 0x0b, 0xbb, 0xc1, 0xe2, 0x4c, 0x04, 0xc5, 0x8c, 0x09, 0x0e, 0xbf, 0x62, 0x48, 0x75, 0x59, |
| 580 | 0x1d, 0x80, 0xdf, 0x60, 0x07, 0xe2, 0x1b, 0x67, 0xa5, 0xbf, 0xcd, 0x86, 0xdc, 0xc3, 0x6a, 0x4e, |
| 581 | 0xd0, 0xfc, 0xd5, 0x3f, 0x98, 0x96, 0x2e, 0x4c, 0xb3, 0xea, 0x2d, 0x75, 0xe6, 0xc0, 0x6c, 0x69, |
| 582 | 0x9b, 0xb7, 0x43, 0x8b, 0x41, 0x47, 0x02, 0xda, 0x98, 0x3d, 0xa3, 0x79, 0x10, 0x4f, 0xb4, 0x55, |
| 583 | 0x5a, 0x25, 0xf4, 0xc8, 0x58, 0x30, 0xc4, 0x12, 0xa9, 0x45, 0xda, 0x91, 0xa4, 0xaa, 0xfc, 0x84, |
| 584 | 0xfa, 0x88, 0x06, 0xce, 0xfe, 0x32, 0xd5, 0x28, 0x1d, 0x19, 0x4b, 0xb1, 0x83, 0xf2, 0x72, 0x26, |
| 585 | }; |
| 586 | |
| 587 | |
| 567 | 588 | static int hackcount = 0; |
| 568 | 589 | static int hackcount2 = 0; |
| 569 | 590 | static int hack_47_value = 0; |
| r24663 | r24664 | |
| 710 | 731 | |
| 711 | 732 | */ |
| 712 | 733 | |
| 713 | | // these table aren't accurate yet, generated with analysis of data sent, we never |
| 714 | | // see the direct results of this operation (happens inside the MCU) |
| 734 | |
| 715 | 735 | |
| 716 | 736 | |
| 717 | | UINT8 puzzli2_level_decode[256] = { |
| 718 | | 0x32, 0x3e, 0xb2, 0x37, 0x31, 0x22, 0xd6, 0x0d, 0x35, 0x5c, 0x8d, 0x3c, 0x7a, 0x5f, 0xd4, 0xad, |
| 719 | | 0x53, 0xff, 0xe9, 0x45, 0xed, 0x11, 0x68, 0x77, 0xd8, 0x34, 0x36, 0x45, 0xa6, 0xeb, 0x1c, 0xc7, |
| 720 | | 0x3b, 0xbd, 0xad, 0x2f, 0x18, 0xde, 0xa1, 0xaa, 0xdd, 0x50, 0x57, 0xc2, 0xe5, 0x0a, 0x01, 0x6d, |
| 721 | | 0x67, 0x65, 0x14, 0x70, 0xb7, 0x39, 0x24, 0x79, 0x83, 0xd2, 0x71, 0xb9, 0x10, 0xf5, 0x92, 0x93, |
| 722 | | 0xfa, 0xe4, 0x5e, 0xb0, 0xf6, 0xaf, 0x95, 0x8a, 0x7d, 0x73, 0xf9, 0x63, 0x86, 0xcb, 0x1a, 0x56, |
| 723 | | 0xf1, 0x3a, 0xae, 0x63, 0x01, 0x29, 0x96, 0x22, 0x8f, 0x5d, 0x9a, 0x65, 0x74, 0x21, 0x20, 0x40, |
| 724 | | 0xd3, 0x05, 0xa2, 0xe3, 0xbc, 0x9e, 0x1e, 0x10, 0x15, 0x0c, 0x8a, 0x9c, 0xec, 0x38, 0xb6, 0x9d, |
| 725 | | 0x2a, 0xf7, 0x14, 0x0e, 0x85, 0xc7, 0x7f, 0xce, 0x94, 0x16, 0x48, 0xa9, 0x80, 0x6e, 0x78, 0xd8, |
| 726 | | 0xa6, 0x7e, 0x42, 0xe4, 0xa2, 0x2b, 0xef, 0xed, 0x24, 0xba, 0xb8, 0x7e, 0xc9, 0x2b, 0x90, 0xcc, |
| 727 | | 0x58, 0xd1, 0xf3, 0xe2, 0x6f, 0xed, 0x9f, 0xf0, 0x4a, 0x54, 0x8d, 0x08, 0xf8, 0x51, 0x68, 0xc8, |
| 728 | | 0x03, 0x0b, 0xbb, 0xc1, 0xe2, 0x4c, 0x04, 0xc5, 0x8c, 0x09, 0x0e, 0xbf, 0x62, 0x48, 0x75, 0x59, |
| 729 | | 0x1d, 0x80, 0xdf, 0x60, 0x07, 0xe2, 0x1b, 0x67, 0xa5, 0xbf, 0xcd, 0x86, 0xdc, 0xc3, 0x6a, 0x4e, |
| 730 | | 0xd0, 0xfc, 0xd5, 0x3f, 0x98, 0x96, 0x2e, 0x4c, 0xb3, 0xea, 0x2d, 0x75, 0xe6, 0xc0, 0x6c, 0x69, |
| 731 | | 0x9b, 0xb7, 0x43, 0x8b, 0x41, 0x47, 0x02, 0xda, 0x98, 0x3d, 0xa3, 0x79, 0x10, 0x4f, 0xb4, 0x55, |
| 732 | | 0x5a, 0x25, 0xf4, 0xc8, 0x58, 0x30, 0xc4, 0x12, 0xa9, 0x45, 0xda, 0x91, 0xa4, 0xaa, 0xfc, 0x84, |
| 733 | | 0xfa, 0x88, 0x06, 0xce, 0xfe, 0x32, 0xd5, 0x28, 0x1d, 0x19, 0x4b, 0xb1, 0x83, 0xf2, 0x72, 0x26, |
| 734 | | }; |
| 737 | |
| 735 | 738 | |
| 736 | 739 | printf("%08x: %02x %04x | ",pc, m_ddp3lastcommand, m_value0); |
| 737 | 740 | |
| r24663 | r24664 | |
| 1818 | 1821 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x500000, 0x500005, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_r),this), write16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_w),this)); |
| 1819 | 1822 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x4f0000, 0x4f003f, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_protram_r),this)); |
| 1820 | 1823 | m_irq4_disabled = 1; // // doesn't like this irq?? |
| 1824 | |
| 1825 | |
| 1826 | #ifdef PUZZLI2_LEVEL_STRUCTURE_LOG |
| 1827 | UINT8 *src2 = (UINT8 *) (machine().root_device().memregion("maincpu")->base()); |
| 1828 | |
| 1829 | int offset; |
| 1830 | int limit; |
| 1831 | |
| 1832 | if (!strcmp(machine().system().name,"puzzli2")) |
| 1833 | { |
| 1834 | offset = 0x17ab66; |
| 1835 | limit = 476; |
| 1836 | } |
| 1837 | else |
| 1838 | { |
| 1839 | offset = 0x16c3ca; |
| 1840 | limit = 500; |
| 1841 | } |
| 1842 | |
| 1843 | |
| 1844 | for (int i=0;i<limit;i++) |
| 1845 | { |
| 1846 | UINT32 val1 = (src2[offset+1]<<24) | (src2[offset+0] << 16) | (src2[offset+3]<<8) | (src2[offset+2] << 0); |
| 1847 | offset += 4; |
| 1848 | UINT32 val2 = (src2[offset+1]<<24) | (src2[offset+0] << 16) | (src2[offset+3]<<8) | (src2[offset+2] << 0); |
| 1849 | |
| 1850 | int stage = 0; |
| 1851 | |
| 1852 | printf("(%d) data range %08x %08x\n", i, val1, val2); |
| 1853 | |
| 1854 | int tableoffs = 0; |
| 1855 | int tableoffs2 = 0; |
| 1856 | int entries_left = 0; |
| 1857 | int currentcolumn = 0; |
| 1858 | int num_entries = 0; |
| 1859 | |
| 1860 | int x = 0; |
| 1861 | for (x=val1; x<val2;x++) |
| 1862 | { |
| 1863 | |
| 1864 | if (x==val1) |
| 1865 | { |
| 1866 | printf("%02x <- table offset\n", src2[x^1]); |
| 1867 | tableoffs = src2[x^1]; |
| 1868 | tableoffs2 = 0; |
| 1869 | } |
| 1870 | else |
| 1871 | { |
| 1872 | |
| 1873 | UINT8 rawvalue = src2[x^1]; |
| 1874 | UINT8 tableloc = (tableoffs+tableoffs2)&0xff; |
| 1875 | rawvalue ^= puzzli2_level_decode[tableloc]; |
| 1876 | |
| 1877 | tableoffs2++; |
| 1878 | tableoffs2&=0xf; |
| 1879 | |
| 1880 | if (stage==0) |
| 1881 | { |
| 1882 | printf("%02x <- Unknown\n", rawvalue); |
| 1883 | stage = 1; |
| 1884 | } |
| 1885 | else if (stage==1) |
| 1886 | { |
| 1887 | printf("%02x <- Number of Entries for this Column (column is %d) (xor table location is %02x) ", rawvalue, currentcolumn, tableloc); |
| 1888 | stage = 2; |
| 1889 | entries_left = (rawvalue >> 4); |
| 1890 | |
| 1891 | num_entries = entries_left; |
| 1892 | |
| 1893 | if (num_entries == 0x00) |
| 1894 | { |
| 1895 | printf("0 entries for this column?"); // seems a valid condition based on the data |
| 1896 | } |
| 1897 | printf("\n"); |
| 1898 | |
| 1899 | |
| 1900 | } |
| 1901 | else if (stage==2) |
| 1902 | { |
| 1903 | printf("%02x <- Mask value equal to number of entries\n", rawvalue); |
| 1904 | stage = 3; |
| 1905 | |
| 1906 | // |
| 1907 | if (entries_left == 0) |
| 1908 | { |
| 1909 | // for 0 entries skip back to state 1 instead of 3, because there is nothing following |
| 1910 | stage = 1; |
| 1911 | } |
| 1912 | |
| 1913 | } |
| 1914 | else if (stage==3) |
| 1915 | { |
| 1916 | printf("%02x <- fish\n", rawvalue); |
| 1917 | entries_left--; |
| 1918 | if (entries_left == 0) |
| 1919 | { |
| 1920 | stage = 1; |
| 1921 | currentcolumn++; |
| 1922 | } |
| 1923 | } |
| 1924 | |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | if (entries_left!=0) |
| 1929 | { |
| 1930 | printf("last column didn't terminate (sometimes this is ok, streams are padded to a word)\n"); |
| 1931 | UINT8 lastbyte = src2[(x-1)^1]; |
| 1932 | printf("last (pre-decrypted) byte in stream was %02x if this is 00 we're probably ok\n", lastbyte); |
| 1933 | } |
| 1934 | |
| 1935 | printf("\n"); |
| 1936 | |
| 1937 | } |
| 1938 | #endif |
| 1939 | |
| 1940 | |
| 1821 | 1941 | } |
| 1822 | 1942 | |
| 1823 | 1943 | DRIVER_INIT_MEMBER(pgm_arm_type1_state,py2k2) |