Previous 199869 Revisions Next

r20051 Friday 4th January, 2013 at 02:32:30 UTC by David Haywood
emulated the bitswaps protection for lhb2 and vbowl/vbowlj instead of patching rom [iq_132]
[src/mame/drivers]igs011.c

trunk/src/mame/drivers/igs011.c
r20050r20051
3838To do:
3939
4040- 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)
4242- Interrupt controller at 838000 or a38000 (there's a preliminary implementation for lhb)
4343- A few graphical bugs
4444
r20050r20051
109109   UINT16 m_lhb_irq_enable;
110110   blitter_t m_blitter;
111111
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
112119   DECLARE_WRITE16_MEMBER(igs011_priority_w);
113120   DECLARE_READ16_MEMBER(igs011_layers_r);
114121   DECLARE_WRITE16_MEMBER(igs011_layers_w);
r20050r20051
15081515//          popmessage("oki %02x",m_lhb2_pen_hi & 0x08);
15091516         break;
15101517
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
15111574      default:
15121575         logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_igs003_reg[0], data);
15131576   }
r20050r20051
15271590         logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_igs003_reg[0]);
15281591         break;
15291592
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;
15321595
15331596      // Protection:
15341597      // 0544FE: 20 21 22 24 25 26 27 28 2A 2B 2C 2D 2E 30 31 32 33 34
r20050r20051
17251788
17261789         break;
17271790
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
17281847      default:
17291848//          popmessage("igs003 %x <- %04x",m_igs003_reg[0],data);
17301849         logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_igs003_reg[0], data);
r20050r20051
17371856      case 0x00:   return ioport("IN0")->read();
17381857      case 0x01:   return ioport("IN1")->read();
17391858
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;
17421861
17431862      case 0x20:   return 0x49;
17441863      case 0x21:   return 0x47;
r20050r20051
20722191
20732192DRIVER_INIT_MEMBER(igs011_state,lhb2)
20742193{
2075   UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base();
2194//  UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base();
20762195
20772196   lhb2_decrypt(machine());
20782197   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*/
20942213}
20952214
20962215DRIVER_INIT_MEMBER(igs011_state,vbowl)
r20050r20051
21092228
21102229   // Patch the bad dump so that it doesn't reboot at the end of a game (the patched value is from vbowlj)
21112230   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*/
21182238}
21192239
21202240
21212241DRIVER_INIT_MEMBER(igs011_state,vbowlj)
21222242{
2123   UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base();
2243//  UINT16 *rom = (UINT16 *) machine().root_device().memregion("maincpu")->base();
21242244   UINT8  *gfx = (UINT8 *)  machine().root_device().memregion("blitter")->base();
21252245   int i;
21262246
r20050r20051
21312251      gfx[i * 2 + 1] = (gfx[i] & 0xf0) >> 4;
21322252      gfx[i * 2 + 0] = (gfx[i] & 0x0f) >> 0;
21332253   }
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*/
21402261}
21412262
21422263

Previous 199869 Revisions Next


© 1997-2024 The MAME Team