trunk/src/mame/drivers/igs011.c
| r20050 | r20051 | |
| 38 | 38 | To do: |
| 39 | 39 | |
| 40 | 40 | - Implement the I/O part of IGS003 as an 8255 |
| 41 | | - IGS003 parametric bitswap protection in lhb2, nkishusp, vbowl (instead of patching the roms) |
| 41 | - IGS003 parametric bitswap protection in nkishusp (instead of patching the roms) |
| 42 | 42 | - Interrupt controller at 838000 or a38000 (there's a preliminary implementation for lhb) |
| 43 | 43 | - A few graphical bugs |
| 44 | 44 | |
| r20050 | r20051 | |
| 109 | 109 | UINT16 m_lhb_irq_enable; |
| 110 | 110 | blitter_t m_blitter; |
| 111 | 111 | |
| 112 | UINT16 m_igs003_prot_hold; |
| 113 | UINT8 m_igs003_prot_x; |
| 114 | UINT8 m_igs003_prot_y; |
| 115 | UINT8 m_igs003_prot_z; |
| 116 | UINT8 m_igs003_prot_h1; |
| 117 | UINT8 m_igs003_prot_h2; |
| 118 | |
| 112 | 119 | DECLARE_WRITE16_MEMBER(igs011_priority_w); |
| 113 | 120 | DECLARE_READ16_MEMBER(igs011_layers_r); |
| 114 | 121 | DECLARE_WRITE16_MEMBER(igs011_layers_w); |
| r20050 | r20051 | |
| 1508 | 1515 | // popmessage("oki %02x",m_lhb2_pen_hi & 0x08); |
| 1509 | 1516 | break; |
| 1510 | 1517 | |
| 1518 | case 0x40: |
| 1519 | m_igs003_prot_h2 = m_igs003_prot_h1; |
| 1520 | m_igs003_prot_h1 = data; |
| 1521 | break; |
| 1522 | |
| 1523 | case 0x41: // data written here is the same as reg 40 |
| 1524 | case 0x42: |
| 1525 | case 0x43: |
| 1526 | case 0x44: |
| 1527 | case 0x45: |
| 1528 | case 0x46: |
| 1529 | case 0x47: |
| 1530 | break; |
| 1531 | |
| 1532 | case 0x48: |
| 1533 | m_igs003_prot_x = 0; // not 100% sure about these |
| 1534 | if(!(m_igs003_prot_h2 & 0x0a)) m_igs003_prot_x |= 0x08; // $100de6 - not used? |
| 1535 | if(!(m_igs003_prot_h2 & 0x90)) m_igs003_prot_x |= 0x04; // $100de7 - not used? |
| 1536 | if(!(m_igs003_prot_h1 & 0x02)) m_igs003_prot_x |= 0x02; // $100de8 |
| 1537 | if(!(m_igs003_prot_h1 & 0x80)) m_igs003_prot_x |= 0x01; // $100de9 |
| 1538 | break; |
| 1539 | |
| 1540 | case 0x50: // reset? |
| 1541 | m_igs003_prot_hold = 0; |
| 1542 | break; |
| 1543 | |
| 1544 | case 0x80: |
| 1545 | case 0x81: |
| 1546 | case 0x82: |
| 1547 | case 0x83: |
| 1548 | case 0x84: |
| 1549 | case 0x85: |
| 1550 | case 0x86: |
| 1551 | case 0x87: |
| 1552 | { |
| 1553 | UINT16 old; |
| 1554 | |
| 1555 | m_igs003_prot_y = m_igs003_reg[0] & 0x07; |
| 1556 | m_igs003_prot_z = data; |
| 1557 | |
| 1558 | old = m_igs003_prot_hold; |
| 1559 | |
| 1560 | m_igs003_prot_hold <<= 1; |
| 1561 | m_igs003_prot_hold |= BIT(old, 15); // rotate |
| 1562 | m_igs003_prot_hold ^= 0x2bad; |
| 1563 | m_igs003_prot_hold ^= BIT(m_igs003_prot_z, m_igs003_prot_y); |
| 1564 | m_igs003_prot_hold ^= BIT(old, 12); |
| 1565 | m_igs003_prot_hold ^= BIT(old, 8); |
| 1566 | m_igs003_prot_hold ^= BIT(old, 3); |
| 1567 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 0) << 4; |
| 1568 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 1) << 6; |
| 1569 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 2) << 10; |
| 1570 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 3) << 12; |
| 1571 | } |
| 1572 | break; |
| 1573 | |
| 1511 | 1574 | default: |
| 1512 | 1575 | logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_igs003_reg[0], data); |
| 1513 | 1576 | } |
| r20050 | r20051 | |
| 1527 | 1590 | logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_igs003_reg[0]); |
| 1528 | 1591 | break; |
| 1529 | 1592 | |
| 1530 | | // case 0x03: |
| 1531 | | // return 0xff; // parametric bitswaps? |
| 1593 | case 0x03: |
| 1594 | return BITSWAP16(m_igs003_prot_hold, 14,11,8,6,4,3,1,0, 5,2,9,7,10,13,12,15) & 0xff; |
| 1532 | 1595 | |
| 1533 | 1596 | // Protection: |
| 1534 | 1597 | // 0544FE: 20 21 22 24 25 26 27 28 2A 2B 2C 2D 2E 30 31 32 33 34 |
| r20050 | r20051 | |
| 1725 | 1788 | |
| 1726 | 1789 | break; |
| 1727 | 1790 | |
| 1791 | case 0x40: |
| 1792 | m_igs003_prot_h2 = m_igs003_prot_h1; |
| 1793 | m_igs003_prot_h1 = data; |
| 1794 | break; |
| 1795 | |
| 1796 | case 0x41: // repeat data written at $40 |
| 1797 | case 0x42: |
| 1798 | case 0x43: |
| 1799 | case 0x44: |
| 1800 | case 0x45: |
| 1801 | case 0x46: |
| 1802 | case 0x47: |
| 1803 | break; |
| 1804 | |
| 1805 | case 0x48: |
| 1806 | m_igs003_prot_x = 0; // not 100% sure about these |
| 1807 | if(!(m_igs003_prot_h2 & 0x0a)) m_igs003_prot_x |= 0x08; |
| 1808 | if(!(m_igs003_prot_h2 & 0x90)) m_igs003_prot_x |= 0x04; |
| 1809 | if(!(m_igs003_prot_h1 & 0x02)) m_igs003_prot_x |= 0x02; |
| 1810 | if(!(m_igs003_prot_h1 & 0x80)) m_igs003_prot_x |= 0x01; |
| 1811 | break; |
| 1812 | |
| 1813 | case 0x50: // reset? |
| 1814 | m_igs003_prot_hold = 0; |
| 1815 | break; |
| 1816 | |
| 1817 | case 0x80: |
| 1818 | case 0x81: |
| 1819 | case 0x82: |
| 1820 | case 0x83: |
| 1821 | case 0x84: |
| 1822 | case 0x85: |
| 1823 | case 0x86: |
| 1824 | case 0x87: |
| 1825 | { |
| 1826 | UINT16 old; |
| 1827 | |
| 1828 | m_igs003_prot_y = m_igs003_reg[0] & 0x07; |
| 1829 | m_igs003_prot_z = data; |
| 1830 | |
| 1831 | old = m_igs003_prot_hold; |
| 1832 | |
| 1833 | m_igs003_prot_hold <<= 1; |
| 1834 | m_igs003_prot_hold ^= BIT(old, 15); // rotate |
| 1835 | m_igs003_prot_hold ^= 0x2bad; |
| 1836 | m_igs003_prot_hold ^= BIT(old, 5); |
| 1837 | m_igs003_prot_hold ^= BIT(old, 8); |
| 1838 | m_igs003_prot_hold ^= BIT(old, 10); |
| 1839 | m_igs003_prot_hold ^= BIT(m_igs003_prot_z, m_igs003_prot_y); |
| 1840 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 0) << 4; |
| 1841 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 1) << 6; |
| 1842 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 2) << 10; |
| 1843 | m_igs003_prot_hold ^= BIT(m_igs003_prot_x, 3) << 12; |
| 1844 | } |
| 1845 | break; |
| 1846 | |
| 1728 | 1847 | default: |
| 1729 | 1848 | // popmessage("igs003 %x <- %04x",m_igs003_reg[0],data); |
| 1730 | 1849 | logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_igs003_reg[0], data); |
| r20050 | r20051 | |
| 1737 | 1856 | case 0x00: return ioport("IN0")->read(); |
| 1738 | 1857 | case 0x01: return ioport("IN1")->read(); |
| 1739 | 1858 | |
| 1740 | | // case 0x03: |
| 1741 | | // return 0xff; // parametric bitswaps? |
| 1859 | case 0x03: |
| 1860 | return BITSWAP16(m_igs003_prot_hold, 14,11,8,6,4,3,1,0, 5,2,9,7,10,13,12,15) & 0xff; |
| 1742 | 1861 | |
| 1743 | 1862 | case 0x20: return 0x49; |
| 1744 | 1863 | case 0x21: return 0x47; |
| r20050 | r20051 | |
| 2072 | 2191 | |
| 2073 | 2192 | DRIVER_INIT_MEMBER(igs011_state,lhb2) |
| 2074 | 2193 | { |
| 2075 | | UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base(); |
| 2194 | // UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base(); |
| 2076 | 2195 | |
| 2077 | 2196 | lhb2_decrypt(machine()); |
| 2078 | 2197 | lhb2_decrypt_gfx(machine()); |
| 2079 | | |
| 2080 | | // PROTECTION CHECKS |
| 2081 | | rom[0x034f4/2] = 0x4e71; // 0034F4: 660E bne 3504 (rom test, fills palette with white otherwise) |
| 2082 | | rom[0x03502/2] = 0x6032; // 003502: 6732 beq 3536 (rom test, fills palette with white otherwise) |
| 2083 | | |
| 2084 | | rom[0x1afea/2] = 0x6034; // 01AFEA: 6734 beq 1b020 (fills palette with black otherwise) |
| 2085 | | // rom[0x24b8a/2] = 0x6036; // 024B8A: 6736 beq 24bc2 (fills palette with green otherwise) |
| 2086 | | // rom[0x29ef8/2] = 0x6036; // 029EF8: 6736 beq 29f30 (fills palette with red otherwise) |
| 2087 | | // rom[0x2e69c/2] = 0x6036; // 02E69C: 6736 beq 2e6d4 (fills palette with green otherwise) |
| 2088 | | // rom[0x2fe96/2] = 0x6036; // 02FE96: 6736 beq 2fece (fills palette with red otherwise) |
| 2089 | | // rom[0x325da/2] = 0x6036; // 0325DA: 6736 beq 32612 (fills palette with green otherwise) |
| 2090 | | rom[0x3d80a/2] = 0x6034; // 03D80A: 6734 beq 3d840 (fills palette with black otherwise) |
| 2091 | | // rom[0x3ed80/2] = 0x6036; // 03ED80: 6736 beq 3edb8 (fills palette with red otherwise) |
| 2092 | | rom[0x41d72/2] = 0x6034; // 041D72: 6734 beq 41da8 (fills palette with black otherwise) |
| 2093 | | rom[0x44834/2] = 0x6034; // 044834: 6734 beq 4486a (fills palette with black otherwise) |
| 2198 | /* |
| 2199 | // PROTECTION CHECKS |
| 2200 | rom[0x034f4/2] = 0x4e71; // 0034F4: 660E bne 3504 (rom test, fills palette with white otherwise) |
| 2201 | rom[0x03502/2] = 0x6032; // 003502: 6732 beq 3536 (rom test, fills palette with white otherwise) |
| 2202 | rom[0x1afea/2] = 0x6034; // 01AFEA: 6734 beq 1b020 (fills palette with black otherwise) |
| 2203 | rom[0x24b8a/2] = 0x6036; // 024B8A: 6736 beq 24bc2 (fills palette with green otherwise) |
| 2204 | rom[0x29ef8/2] = 0x6036; // 029EF8: 6736 beq 29f30 (fills palette with red otherwise) |
| 2205 | rom[0x2e69c/2] = 0x6036; // 02E69C: 6736 beq 2e6d4 (fills palette with green otherwise) |
| 2206 | rom[0x2fe96/2] = 0x6036; // 02FE96: 6736 beq 2fece (fills palette with red otherwise) |
| 2207 | rom[0x325da/2] = 0x6036; // 0325DA: 6736 beq 32612 (fills palette with green otherwise) |
| 2208 | rom[0x3d80a/2] = 0x6034; // 03D80A: 6734 beq 3d840 (fills palette with black otherwise) |
| 2209 | rom[0x3ed80/2] = 0x6036; // 03ED80: 6736 beq 3edb8 (fills palette with red otherwise) |
| 2210 | rom[0x41d72/2] = 0x6034; // 041D72: 6734 beq 41da8 (fills palette with black otherwise) |
| 2211 | rom[0x44834/2] = 0x6034; // 044834: 6734 beq 4486a (fills palette with black otherwise) |
| 2212 | */ |
| 2094 | 2213 | } |
| 2095 | 2214 | |
| 2096 | 2215 | DRIVER_INIT_MEMBER(igs011_state,vbowl) |
| r20050 | r20051 | |
| 2109 | 2228 | |
| 2110 | 2229 | // Patch the bad dump so that it doesn't reboot at the end of a game (the patched value is from vbowlj) |
| 2111 | 2230 | rom[0x080e0/2] = 0xe549; // 0080E0: 0449 dc.w $0449; ILLEGAL |
| 2112 | | |
| 2113 | | // PROTECTION CHECKS |
| 2114 | | // rom[0x03764/2] = 0x4e75; // 003764: 4E56 0000 link A6, #$0 |
| 2115 | | rom[0x173ee/2] = 0x600c; // 0173EE: 670C beq $173fc |
| 2116 | | rom[0x1e6e6/2] = 0x600c; // 01E6E6: 670C beq $1e6f4 |
| 2117 | | rom[0x1f7ce/2] = 0x600c; // 01F7CE: 670C beq $1f7dc |
| 2231 | /* |
| 2232 | // PROTECTION CHECKS |
| 2233 | rom[0x03764/2] = 0x4e75; // 003764: 4E56 0000 link A6, #$0 |
| 2234 | rom[0x173ee/2] = 0x600c; // 0173EE: 670C beq $173fc |
| 2235 | rom[0x1e6e6/2] = 0x600c; // 01E6E6: 670C beq $1e6f4 |
| 2236 | rom[0x1f7ce/2] = 0x600c; // 01F7CE: 670C beq $1f7dc |
| 2237 | */ |
| 2118 | 2238 | } |
| 2119 | 2239 | |
| 2120 | 2240 | |
| 2121 | 2241 | DRIVER_INIT_MEMBER(igs011_state,vbowlj) |
| 2122 | 2242 | { |
| 2123 | | UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base(); |
| 2243 | // UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base(); |
| 2124 | 2244 | UINT8 *gfx = (UINT8 *) machine().root_device().memregion("blitter")->base(); |
| 2125 | 2245 | int i; |
| 2126 | 2246 | |
| r20050 | r20051 | |
| 2131 | 2251 | gfx[i * 2 + 1] = (gfx[i] & 0xf0) >> 4; |
| 2132 | 2252 | gfx[i * 2 + 0] = (gfx[i] & 0x0f) >> 0; |
| 2133 | 2253 | } |
| 2134 | | |
| 2135 | | // PROTECTION CHECKS |
| 2136 | | // rom[0x37b4/2] = 0x4e75; // 0037B4: 4E56 0000 link A6, #$0 |
| 2137 | | rom[0x17720/2] = 0x600c; // 017720: 670C beq 1772e |
| 2138 | | rom[0x1e6e6/2] = 0x600c; // 01E6E6: 670C beq $1e6f4 |
| 2139 | | rom[0x1f7c8/2] = 0x600c; // 01F7C8: 670C beq 1f7d6 |
| 2254 | /* |
| 2255 | // PROTECTION CHECKS |
| 2256 | rom[0x37b4/2] = 0x4e75; // 0037B4: 4E56 0000 link A6, #$0 |
| 2257 | rom[0x17720/2] = 0x600c; // 017720: 670C beq 1772e |
| 2258 | rom[0x1e6e6/2] = 0x600c; // 01E6E6: 670C beq $1e6f4 |
| 2259 | rom[0x1f7c8/2] = 0x600c; // 01F7C8: 670C beq 1f7d6 |
| 2260 | */ |
| 2140 | 2261 | } |
| 2141 | 2262 | |
| 2142 | 2263 | |