~ubuntu-branches/ubuntu/precise/mame/precise-proposed

« back to all changes in this revision

Viewing changes to src/mame/drivers/igs017.c

  • Committer: Package Import Robot
  • Author(s): Cesare Falco
  • Date: 2011-11-30 18:50:10 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111130185010-02hcxybht1mn082w
Tags: 0.144-0ubuntu1
* New upstream release (LP: #913550)
* mame.install:
  - Added artwork/ images to be used with -effect switch
  - Be more selective with hash/ contents
* contrib/mame.ini: added /usr/share/games/mame/artwork/ to artpath

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
- Protection emulation, instead of patching the roms.
30
30
- NVRAM.
31
 
- tjsb: finish sprites decryption (data lines scrambling), protection, inputs.
32
31
- iqblockf: protection.
33
 
- mgcs: implement joystick inputs
 
32
- mgcs: implement joystick inputs. Sound banking and DSW go through protection.
34
33
 
35
34
Notes:
36
35
 
37
36
- iqblocka: keep start or test pressed during boot to enter test mode A or B.
38
 
- mgcs: press service + stats during test mode for sound test.
 
37
- mgcs, tjsb: press service + stats during test mode for sound test.
39
38
- mgdh: press A + B during test mode for sound test (B1+B2+B3 when using a joystick).
40
39
- mgdh: test mode is accessed by keeping test pressed during boot (as usual), but pressing F2+F3 in MAME
41
40
  does not actually work. It does work if F2 is pressed in the debug window at boot, and held while closing it.
184
183
        int i;
185
184
 
186
185
        state->m_sprites_gfx_size       =       size / 2 * 3;
187
 
        state->m_sprites_gfx                    =       auto_alloc_array(machine, UINT8, state->m_sprites_gfx_size);
 
186
        state->m_sprites_gfx            =       auto_alloc_array(machine, UINT8, state->m_sprites_gfx_size);
188
187
 
189
188
        for (i = 0; i < size / 2 ; i++)
190
189
        {
478
477
        int length = machine.region("sprites")->bytes();
479
478
        UINT8 *rom = machine.region("sprites")->base();
480
479
        UINT8 *tmp = auto_alloc_array(machine, UINT8, length);
481
 
        int i;
 
480
        int i, addr;
482
481
 
483
482
        // address lines swap (to do: collapse into one bitswap)
484
 
        memcpy(tmp,rom,length);
485
 
        for (i = 0;i < length;i++)
486
 
        {
487
 
                int addr = (i & ~0xff) | BITSWAP8(i,7,6,5,4,1,2,3,0);
488
 
                rom[i] = tmp[addr];
489
 
        }
490
 
 
491
 
        memcpy(tmp,rom,length);
492
 
        for (i = 0;i < length;i++)
493
 
        {
494
 
                int addr = (i & ~0xff) | BITSWAP8(i,7,6,5,2,4,3,1,0);
495
 
                rom[i] = tmp[addr];
496
 
        }
497
 
 
498
 
        memcpy(tmp,rom,length);
499
 
        for (i = 0;i < length;i++)
500
 
        {
501
 
                int addr = (i & ~0xff) | BITSWAP8(i,7,6,5,3,4,2,1,0);
502
 
                rom[i] = BITSWAP8(tmp[addr],7,6,5,4,3,2,1,0);
503
 
        }
504
 
}
505
 
 
506
 
static void tjsb_patch_rom(running_machine &machine)
507
 
{
508
 
        UINT8 *rom = machine.region("maincpu")->base();
509
 
        rom[0x011df] = 0x18;
 
483
        memcpy(tmp, rom, length);
 
484
        for (i = 0; i < length; i++)
 
485
        {
 
486
                addr = (i & ~0xff) | BITSWAP8(i,7,6,5,4,1,2,3,0);
 
487
                rom[i] = tmp[addr];
 
488
        }
 
489
 
 
490
        memcpy(tmp, rom, length);
 
491
        for (i = 0; i < length; i++)
 
492
        {
 
493
                addr = (i & ~0xff) | BITSWAP8(i,7,6,5,2,4,3,1,0);
 
494
                rom[i] = tmp[addr];
 
495
        }
 
496
 
 
497
        memcpy(tmp, rom, length);
 
498
        for (i = 0; i < length; i++)
 
499
        {
 
500
                addr = (i & ~0xff) | BITSWAP8(i,7,6,5,3,4,2,1,0);
 
501
                rom[i] = tmp[addr];
 
502
        }
 
503
 
 
504
        // data lines swap
 
505
        for (i = 0; i < length; i += 2)
 
506
        {
 
507
                // x-22222-11111-00000
 
508
                UINT16 data = (rom[i+1] << 8) | rom[i+0];
 
509
                data = BITSWAP16(data, 15, 14,13,12,11,10, 9,1,7,6,5, 4,3,2,8,0);
 
510
                rom[i+1] = data >> 8;
 
511
                rom[i+0] = data;
 
512
        }
510
513
}
511
514
 
512
515
static DRIVER_INIT( tjsb )
513
516
{
514
517
        decrypt_program_rom(machine, 0x05, 7, 6, 3, 2, 5, 4, 1, 0);
515
 
        tjsb_patch_rom(machine);
516
518
 
517
519
        tjsb_decrypt_sprites(machine);
518
520
}
681
683
 
682
684
// starzan
683
685
 
684
 
// decryption is incomplete, the first part of code doesn't seem right.
685
 
static DRIVER_INIT( starzan )
 
686
// decryption is incomplete, data encryption is correct but opcodes are encrypted differently.
 
687
 
 
688
static void starzan_decrypt(UINT8 *ROM, int size, bool isOpcode)
686
689
{
687
 
        UINT8 *ROM = machine.region("maincpu")->base();
688
 
        int i;
689
 
        int size = 0x040000;
690
 
 
691
 
        for(i=0; i<size; i++)
 
690
        for(int i=0; i<size; i++)
692
691
        {
 
692
#if 1
693
693
                UINT8 x = ROM[i];
694
694
 
695
 
#if 1
 
695
                // this seems ok for opcodes too
696
696
                if ( (i & 0x10) && (i & 0x01) )
697
697
                {
698
698
                        if ( !(!(i & 0x2000) && !(i & 0x100) && !(i & 0x80)) )
704
704
                                x ^= 0x01;
705
705
                }
706
706
 
707
 
                if ( ((i & 0xf000)<0xe000) && (!(i & 0x100) || (i & 0x80) || (i & 0x20)) )
 
707
                // 2x no xor (opcode)
 
708
                // 3x no xor (opcode)
 
709
                // 60-66 no xor (opcode)
 
710
                if ( !(i & 0x100) || (i & 0x80) || (i & 0x20) )
708
711
                        x ^= 0x20;
709
712
 
710
 
                if ( !(!(i & 0x200) && !(i & 0x40) && (i & 0x20)) )
 
713
                // 2x needs xor (opcode)
 
714
                // 3x needs xor (opcode)
 
715
                if ( (i & 0x200) || (i & 0x40) || !(i & 0x20) )
711
716
                        x ^= 0x40;
712
717
 
713
 
                if ( ((i & 0xf000)<0xe000) && ((!(i & 0x100) && (i & 0x80)) || (i & 0x20)) )
 
718
                if ( (!(i & 0x100) && (i & 0x80)) || (i & 0x20) )
714
719
                        x ^= 0x80;
715
720
 
716
 
//if ( (i & 0xffff) < 0x20 )
717
 
//  x ^= 0x80;
718
721
#else
719
722
                // by iq_132
720
723
                if ((i & 0x00011) == 0x00011) x ^= 0x01;
726
729
                if ((i & 0x00020) == 0x00020) x ^= 0x80;
727
730
                if ((i & 0x001a0) == 0x00080) x ^= 0x80;
728
731
#endif
729
 
 
730
732
                ROM[i] = x;
731
733
        }
 
734
}
 
735
 
 
736
static DRIVER_INIT( starzan )
 
737
{
 
738
        int size = 0x040000;
 
739
 
 
740
        UINT8 *data = machine.region("maincpu")->base();
 
741
        UINT8 *code = auto_alloc_array(machine, UINT8, size);
 
742
        memcpy(code, data, size);
 
743
 
 
744
        starzan_decrypt(data, size, false);     // data
 
745
        starzan_decrypt(code, size, true);      // opcodes
 
746
 
 
747
        machine.device("maincpu")->memory().space(AS_PROGRAM)->set_decrypted_region(0x00000, 0x3ffff, code);
732
748
 
733
749
        mgcs_flip_sprites(machine);
734
750
}
1257
1273
                logerror("PC %06X: irq2_enable = %04x\n",cpu_get_pc(&space->device()),data);
1258
1274
}
1259
1275
 
1260
 
static WRITE16_HANDLER( mgcs_paletteram_xRRRRRGGGGGBBBBB_w )
 
1276
static WRITE16_HANDLER( mgcs_paletteram_w )
1261
1277
{
1262
 
        int rgb;
1263
 
 
1264
1278
        COMBINE_DATA(&space->machine().generic.paletteram.u16[offset]);
1265
1279
 
1266
 
        rgb = ((space->machine().generic.paletteram.u16[offset/2*2+0] & 0xff) << 8) | (space->machine().generic.paletteram.u16[offset/2*2+1] & 0xff);
 
1280
        int bgr = ((space->machine().generic.paletteram.u16[offset/2*2+0] & 0xff) << 8) | (space->machine().generic.paletteram.u16[offset/2*2+1] & 0xff);
1267
1281
 
1268
1282
        // bitswap
1269
 
        rgb = BITSWAP16(rgb,7,8,9,2,14,3,13,15,12,11,10,0,1,4,5,6);
 
1283
        bgr = BITSWAP16(bgr, 7,8,9,2,14,3,13,15,12,11,10,0,1,4,5,6);
1270
1284
 
1271
 
        palette_set_color_rgb(space->machine(), offset/2, pal5bit(rgb >> 0), pal5bit(rgb >> 5), pal5bit(rgb >> 10));
 
1285
        palette_set_color_rgb(space->machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
1272
1286
}
1273
1287
 
1274
1288
static ADDRESS_MAP_START( mgcs, AS_PROGRAM, 16 )
1277
1291
        AM_RANGE( 0x49c000, 0x49c003 ) AM_WRITE( mgcs_magic_w )
1278
1292
        AM_RANGE( 0x49c002, 0x49c003 ) AM_READ ( mgcs_magic_r )
1279
1293
        AM_RANGE( 0xa02000, 0xa02fff ) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_BASE_MEMBER(igs017_state, m_spriteram)
1280
 
        AM_RANGE( 0xa03000, 0xa037ff ) AM_RAM_WRITE( mgcs_paletteram_xRRRRRGGGGGBBBBB_w ) AM_BASE_GENERIC( paletteram )
 
1294
        AM_RANGE( 0xa03000, 0xa037ff ) AM_RAM_WRITE( mgcs_paletteram_w ) AM_BASE_GENERIC( paletteram )
1281
1295
        AM_RANGE( 0xa04020, 0xa04027 ) AM_DEVREAD8( "ppi8255", ppi8255_r, 0x00ff )
1282
1296
        AM_RANGE( 0xa04024, 0xa04025 ) AM_WRITE( video_disable_lsb_w )
1283
1297
        AM_RANGE( 0xa04028, 0xa04029 ) AM_WRITE( irq2_enable_w )
1291
1305
 
1292
1306
// sdmg2
1293
1307
 
1294
 
static WRITE16_HANDLER( sdmg2_paletteram_xRRRRRGGGGGBBBBB_w )
 
1308
static WRITE16_HANDLER( sdmg2_paletteram_w )
1295
1309
{
1296
 
        int rgb;
1297
 
 
1298
1310
        COMBINE_DATA(&space->machine().generic.paletteram.u16[offset]);
1299
1311
 
1300
 
        rgb = ((space->machine().generic.paletteram.u16[offset/2*2+1] & 0xff) << 8) | (space->machine().generic.paletteram.u16[offset/2*2+0] & 0xff);
 
1312
        int bgr = ((space->machine().generic.paletteram.u16[offset/2*2+1] & 0xff) << 8) | (space->machine().generic.paletteram.u16[offset/2*2+0] & 0xff);
1301
1313
 
1302
 
        palette_set_color_rgb(space->machine(), offset/2, pal5bit(rgb >> 0), pal5bit(rgb >> 5), pal5bit(rgb >> 10));
 
1314
        palette_set_color_rgb(space->machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
1303
1315
}
1304
1316
 
1305
1317
static READ8_HANDLER( sdmg2_keys_r )
1378
1390
        AM_RANGE(0x000000, 0x07ffff) AM_ROM
1379
1391
        AM_RANGE(0x1f0000, 0x1fffff) AM_RAM
1380
1392
        AM_RANGE(0x202000, 0x202fff) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_BASE_MEMBER(igs017_state, m_spriteram)
1381
 
        AM_RANGE(0x203000, 0x2037ff) AM_RAM_WRITE( sdmg2_paletteram_xRRRRRGGGGGBBBBB_w ) AM_BASE_GENERIC( paletteram )
 
1393
        AM_RANGE(0x203000, 0x2037ff) AM_RAM_WRITE( sdmg2_paletteram_w ) AM_BASE_GENERIC( paletteram )
1382
1394
        AM_RANGE(0x204020, 0x204027) AM_DEVREAD8( "ppi8255", ppi8255_r, 0x00ff )
1383
1395
        AM_RANGE(0x204024, 0x204025) AM_WRITE( video_disable_lsb_w )
1384
1396
        AM_RANGE(0x204028, 0x204029) AM_WRITE( irq2_enable_w )
1501
1513
        AM_RANGE(0x876000, 0x876003) AM_WRITE( mgdha_magic_w )
1502
1514
        AM_RANGE(0x876002, 0x876003) AM_READ ( mgdha_magic_r )
1503
1515
        AM_RANGE(0xa02000, 0xa02fff) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_BASE_MEMBER(igs017_state, m_spriteram)
1504
 
        AM_RANGE(0xa03000, 0xa037ff) AM_RAM_WRITE( sdmg2_paletteram_xRRRRRGGGGGBBBBB_w ) AM_BASE_GENERIC( paletteram )
 
1516
        AM_RANGE(0xa03000, 0xa037ff) AM_RAM_WRITE( sdmg2_paletteram_w ) AM_BASE_GENERIC( paletteram )
1505
1517
//  AM_RANGE(0xa04014, 0xa04015) // written with FF at boot
1506
1518
        AM_RANGE(0xa04020, 0xa04027) AM_DEVREAD8( "ppi8255", ppi8255_r, 0x00ff )
1507
1519
        AM_RANGE(0xa04024, 0xa04025) AM_WRITE( video_disable_lsb_w )
1513
1525
ADDRESS_MAP_END
1514
1526
 
1515
1527
 
 
1528
// tjsb
 
1529
 
 
1530
static WRITE8_HANDLER( tjsb_paletteram_w )
 
1531
{
 
1532
        space->machine().generic.paletteram.u8[offset] = data;
 
1533
        int bgr = (space->machine().generic.paletteram.u8[offset/2*2+1] << 8) | space->machine().generic.paletteram.u8[offset/2*2+0];
 
1534
 
 
1535
        // bitswap
 
1536
        bgr = BITSWAP16(bgr, 15, 12,3,6,10,5, 4,2,9,13,8, 7,11,1,0,14);
 
1537
 
 
1538
        palette_set_color_rgb(space->machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
 
1539
}
 
1540
 
 
1541
static WRITE8_HANDLER( tjsb_output_w )
 
1542
{
 
1543
        igs017_state *state = space->machine().driver_data<igs017_state>();
 
1544
        switch(state->m_input_select)
 
1545
        {
 
1546
                case 0x00:
 
1547
                        coin_counter_w(space->machine(), 0,     data & 0x80);   // coin in
 
1548
                        if (!(data & ~0x80))
 
1549
                                return;
 
1550
                        break;
 
1551
 
 
1552
                case 0x01:
 
1553
                        coin_counter_w(space->machine(), 1,     data & 0x01);   // coin out
 
1554
                        if (!(data & ~0x01))
 
1555
                                return;
 
1556
                        break;
 
1557
 
 
1558
                case 0x02:
 
1559
                        space->machine().device<okim6295_device>("oki")->set_bank_base((data & 0x10) ? 0x40000 : 0);    // oki bank (0x20/0x30)
 
1560
                        if (!(data & ~0x30))
 
1561
                                return;
 
1562
                        break;
 
1563
 
 
1564
                case 0x03:
 
1565
                        state->m_hopper = data & 0x40;
 
1566
                        if (!(data & ~0x40))
 
1567
                                return;
 
1568
                        break;
 
1569
        }
 
1570
        logerror("%06x: warning, writing to igs_magic %02x = %02x\n", cpu_get_pc(&space->device()), state->m_input_select, data);
 
1571
}
 
1572
 
 
1573
static READ8_HANDLER( tjsb_input_r )
 
1574
{
 
1575
        igs017_state *state = space->machine().driver_data<igs017_state>();
 
1576
        switch (state->m_input_select)
 
1577
        {
 
1578
                case 0x00:      return input_port_read(space->machine(), "PLAYER1");
 
1579
                case 0x01:      return input_port_read(space->machine(), "PLAYER2");
 
1580
                case 0x02:      return input_port_read(space->machine(), "COINS");
 
1581
                case 0x03:
 
1582
                {
 
1583
                        UINT8 hopper_bit = (state->m_hopper && ((space->machine().primary_screen->frame_number()/10)&1)) ? 0x00 : 0x20;
 
1584
                        return input_port_read(space->machine(), "HOPPER") | hopper_bit;
 
1585
                }
 
1586
 
 
1587
                default:
 
1588
                        logerror("PC %06X: input %02x read\n",cpu_get_pc(&space->device()),state->m_input_select);
 
1589
                        return 0xff;
 
1590
        }
 
1591
}
 
1592
 
 
1593
static ADDRESS_MAP_START( tjsb_map, AS_PROGRAM, 8 )
 
1594
        AM_RANGE( 0x00000, 0x0dfff ) AM_ROM
 
1595
        AM_RANGE( 0x0e000, 0x0e000 ) AM_WRITE( input_select_w )
 
1596
        AM_RANGE( 0x0e001, 0x0e001 ) AM_READWRITE( tjsb_input_r, tjsb_output_w )
 
1597
        AM_RANGE( 0x0e002, 0x0efff ) AM_RAM
 
1598
        AM_RANGE( 0x0f000, 0x0ffff ) AM_RAM
 
1599
        AM_RANGE( 0x10000, 0x3ffff ) AM_ROM
 
1600
ADDRESS_MAP_END
 
1601
 
 
1602
static ADDRESS_MAP_START( tjsb_io, AS_IO, 8 )
 
1603
        AM_RANGE( 0x0000, 0x003f ) AM_RAM // internal regs
 
1604
 
 
1605
        AM_RANGE( 0x1000, 0x17ff ) AM_RAM AM_BASE_MEMBER(igs017_state, m_spriteram)
 
1606
        AM_RANGE( 0x1800, 0x1bff ) AM_RAM_WRITE( tjsb_paletteram_w ) AM_BASE_GENERIC(paletteram)
 
1607
        AM_RANGE( 0x1c00, 0x1fff ) AM_RAM
 
1608
 
 
1609
//  AM_RANGE(0x200a, 0x200a) AM_WRITENOP
 
1610
 
 
1611
        AM_RANGE( 0x2010, 0x2013 ) AM_DEVREAD("ppi8255", ppi8255_r)
 
1612
        AM_RANGE( 0x2012, 0x2012 ) AM_WRITE( video_disable_w )
 
1613
 
 
1614
        AM_RANGE( 0x2014, 0x2014 ) AM_WRITE( nmi_enable_w )
 
1615
        AM_RANGE( 0x2015, 0x2015 ) AM_WRITE( irq_enable_w )
 
1616
 
 
1617
        AM_RANGE( 0x4000, 0x5fff ) AM_RAM_WRITE( fg_w ) AM_BASE_MEMBER(igs017_state, m_fg_videoram )
 
1618
        AM_RANGE( 0x6000, 0x7fff ) AM_RAM_WRITE( bg_w ) AM_BASE_MEMBER(igs017_state, m_bg_videoram )
 
1619
 
 
1620
        AM_RANGE( 0x9000, 0x9000 ) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
 
1621
 
 
1622
        AM_RANGE( 0xb000, 0xb001 ) AM_DEVWRITE( "ymsnd", ym2413_w )
 
1623
ADDRESS_MAP_END
 
1624
 
 
1625
 
1516
1626
/***************************************************************************
1517
1627
                                Input Ports
1518
1628
***************************************************************************/
1688
1798
        // the top 2 bits of COINS (port A) and KEYx (port B) are read and combined with the bottom 4 bits read from port C (see code at 1C83A)
1689
1799
 
1690
1800
        PORT_START("COINS")
1691
 
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE2 ) // ? (shown in service mode)
1692
 
        PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW ) // service mode (keep pressed during boot too)
1693
 
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Statistics")   // press with the above for sound test
1694
 
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1    ) PORT_IMPULSE(5)
1695
 
        PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER    ) PORT_NAME("Pay Out") PORT_CODE(KEYCODE_O)
1696
 
        PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE3 ) // ? (shown in service mode)
1697
 
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN  )
1698
 
        PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN  )
 
1801
        PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SERVICE2 ) // hopper switch (unimplemented)
 
1802
        PORT_SERVICE_NO_TOGGLE( 0x02,   IP_ACTIVE_LOW ) // service mode (keep pressed during boot too)
 
1803
        PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_SERVICE1 ) PORT_NAME("Statistics")  // press with the above for sound test
 
1804
        PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_COIN1    ) PORT_IMPULSE(5)
 
1805
        PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_OTHER    ) PORT_NAME("Pay Out") PORT_CODE(KEYCODE_O)
 
1806
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE3 ) // ? must be high to display numbers (shown in service mode)
 
1807
        PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
 
1808
        PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
1699
1809
 
1700
1810
        PORT_START("KEY0")
1701
1811
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
2009
2119
 
2010
2120
INPUT_PORTS_END
2011
2121
 
 
2122
static INPUT_PORTS_START( tjsb )
 
2123
 
 
2124
        PORT_START("DSW1")
 
2125
        PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
 
2126
        PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
 
2127
        PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
 
2128
        PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
 
2129
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
 
2130
        PORT_DIPNAME( 0x0c, 0x0c, "Credits Per Note" )
 
2131
        PORT_DIPSETTING(    0x0c, "10" )
 
2132
        PORT_DIPSETTING(    0x08, "20" )
 
2133
        PORT_DIPSETTING(    0x04, "50" )
 
2134
        PORT_DIPSETTING(    0x00, "100" )
 
2135
        PORT_DIPNAME( 0x10, 0x10, "Max Note Credits" )
 
2136
        PORT_DIPSETTING(    0x10, "1000" )
 
2137
        PORT_DIPSETTING(    0x00, "5000" )
 
2138
        PORT_DIPNAME( 0x20, 0x20, "Money Type" )
 
2139
        PORT_DIPSETTING(    0x20, "Coins" )
 
2140
        PORT_DIPSETTING(    0x00, "Notes" )
 
2141
        PORT_DIPNAME( 0x40, 0x40, "Pay Out Type" )      // 2/4
 
2142
        PORT_DIPSETTING(    0x40, "Coins" )
 
2143
        PORT_DIPSETTING(    0x00, "Notes" )
 
2144
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
 
2145
        PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
 
2146
        PORT_DIPSETTING(    0x80, DEF_STR( On ) )
 
2147
 
 
2148
        PORT_START("DSW2")
 
2149
        PORT_DIPNAME( 0x03, 0x03, "Min Bet" )
 
2150
        PORT_DIPSETTING(    0x03, "1000" )
 
2151
        PORT_DIPSETTING(    0x02, "2000" )
 
2152
        PORT_DIPSETTING(    0x01, "3000" )
 
2153
        PORT_DIPSETTING(    0x00, "4000" )
 
2154
        PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Unknown ) )
 
2155
        PORT_DIPSETTING(    0x0c, "1" )
 
2156
        PORT_DIPSETTING(    0x08, "3" )
 
2157
        PORT_DIPSETTING(    0x04, "5" )
 
2158
        PORT_DIPSETTING(    0x00, "10" )
 
2159
        PORT_DIPNAME( 0x10, 0x10, "Bonus Round" )       // show bonus round in demo mode -> protection check
 
2160
        PORT_DIPSETTING(    0x00, DEF_STR( No ) )
 
2161
        PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
 
2162
        PORT_DIPNAME( 0x20, 0x20, "Number Type" )
 
2163
        PORT_DIPSETTING(    0x20, "Number" )
 
2164
        PORT_DIPSETTING(    0x00, "Dice" )
 
2165
        PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
 
2166
        PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
 
2167
        PORT_DIPSETTING(    0x00, DEF_STR( On ) )
 
2168
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
 
2169
        PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
 
2170
        PORT_DIPSETTING(    0x00, DEF_STR( On ) )
 
2171
 
 
2172
        PORT_START("DSW3")      // check: (val^ff) & 9a == 0a
 
2173
        PORT_DIPNAME( 0xff, 0xf5, "Bonus Round Protection Check" )
 
2174
        PORT_DIPSETTING(    0xf5, DEF_STR( Off ) )
 
2175
        PORT_DIPSETTING(    0xff, DEF_STR( On ) )
 
2176
 
 
2177
        PORT_START("PLAYER1")
 
2178
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1         )     PORT_NAME("Start / Don Den")
 
2179
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    )
 
2180
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  )
 
2181
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  )
 
2182
        PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
 
2183
        PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1        ) // choose
 
2184
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2        ) // bet
 
2185
        PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN        )
 
2186
 
 
2187
        PORT_START("PLAYER2")
 
2188
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2189
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2190
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2191
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2192
        PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2193
        PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2194
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2195
        PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2196
 
 
2197
        PORT_START("COINS")
 
2198
        PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SERVICE1  ) PORT_NAME("Statistics")
 
2199
        PORT_SERVICE_NO_TOGGLE( 0x02,   IP_ACTIVE_LOW ) // keep pressed while booting
 
2200
        PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
 
2201
        PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
 
2202
        PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
 
2203
        PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
 
2204
        PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
 
2205
        PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_COIN1     )
 
2206
 
 
2207
        PORT_START("HOPPER")
 
2208
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 )
 
2209
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // ? shown in test mode
 
2210
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2211
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2212
        PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Pay Out") PORT_CODE(KEYCODE_O)
 
2213
        PORT_BIT( 0x20, IP_ACTIVE_HIGH,IPT_SPECIAL ) // hopper switch
 
2214
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2215
        PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
 
2216
 
 
2217
INPUT_PORTS_END
 
2218
 
2012
2219
 
2013
2220
/***************************************************************************
2014
2221
                                Graphics Layout
2308
2515
MACHINE_CONFIG_END
2309
2516
 
2310
2517
 
 
2518
// tjsb
 
2519
 
 
2520
static MACHINE_CONFIG_START( tjsb, igs017_state )
 
2521
        MCFG_CPU_ADD("maincpu", Z180, XTAL_16MHz / 2)
 
2522
        MCFG_CPU_PROGRAM_MAP(tjsb_map)
 
2523
        MCFG_CPU_IO_MAP(tjsb_io)
 
2524
        MCFG_CPU_VBLANK_INT_HACK(iqblocka_interrupt,2)
 
2525
 
 
2526
        MCFG_PPI8255_ADD( "ppi8255", iqblocka_ppi8255_intf )
 
2527
 
 
2528
        MCFG_MACHINE_RESET(iqblocka)
 
2529
 
 
2530
        /* video hardware */
 
2531
        MCFG_SCREEN_ADD("screen", RASTER)
 
2532
        MCFG_SCREEN_REFRESH_RATE(60)
 
2533
        MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
 
2534
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
 
2535
        MCFG_SCREEN_SIZE(512, 256)
 
2536
        MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 240-1)
 
2537
        MCFG_SCREEN_UPDATE(igs017)
 
2538
 
 
2539
        MCFG_GFXDECODE(igs017)
 
2540
        MCFG_PALETTE_LENGTH(0x100*2)
 
2541
 
 
2542
        MCFG_VIDEO_START(igs017)
 
2543
        MCFG_VIDEO_RESET(igs017)
 
2544
 
 
2545
        /* sound hardware */
 
2546
        MCFG_SPEAKER_STANDARD_MONO("mono")
 
2547
        MCFG_SOUND_ADD("ymsnd", YM2413, XTAL_3_579545MHz)
 
2548
        MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
 
2549
 
 
2550
        MCFG_OKIM6295_ADD("oki", XTAL_16MHz / 16, OKIM6295_PIN7_HIGH)
 
2551
        MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
 
2552
MACHINE_CONFIG_END
 
2553
 
 
2554
 
2311
2555
/***************************************************************************
2312
2556
                                ROMs Loading
2313
2557
***************************************************************************/
2436
2680
        ROM_REGION( 0x40000, "maincpu", 0 )
2437
2681
        ROM_LOAD( "p0700.u16", 0x00000, 0x40000,CRC(1b2a50df) SHA1(95a272e624f727df9523667864f933118d9e633c) )
2438
2682
 
2439
 
        ROM_REGION( 0x200000, "sprites", 0 )
2440
 
        ROM_LOAD( "a0701.u3", 0x000000, 0x200000, CRC(aa182140) SHA1(37c2053386c183ff726ba417d13f2063cf9a22df) )        // FIXED BITS (xxxxxxxx0xxxxxxx)
 
2683
        ROM_REGION( 0x400000, "sprites", 0 )
 
2684
        ROM_LOAD( "a0701.u3", 0x00000, 0x400000, CRC(27502a0a) SHA1(cca79e253697f47b688ef781b1b6de9d2945f199) ) // FIXED BITS (xxxxxxxx0xxxxxxx)
2441
2685
 
2442
2686
        ROM_REGION( 0x80000, "tilemaps", 0 )
2443
2687
        ROM_LOAD( "text.u6", 0x00000, 0x80000,  CRC(3be886b8) SHA1(15b3624ed076640c1828d065b01306a8656f5a9b) )  // BADADDR --xxxxxxxxxxxxxxxxx
2892
3136
 
2893
3137
GAME( 1996,  iqblocka, iqblock, iqblocka, iqblocka, iqblocka, ROT0, "IGS",              "Shu Zi Le Yuan (V127M)",                      GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
2894
3138
GAME( 1996,  iqblockf, iqblock, iqblocka, iqblocka, iqblockf, ROT0, "IGS",              "Shu Zi Le Yuan (V113FR)",                     GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
2895
 
GAME( 1997,  tjsb,     0,       iqblocka, iqblocka, tjsb,     ROT0, "IGS",              "Mahjong Tian Jiang Shen Bing",                GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
 
3139
GAME( 1997,  tjsb,     0,       tjsb,     tjsb,     tjsb,     ROT0, "IGS",              "Mahjong Tian Jiang Shen Bing (V137C)",        GAME_UNEMULATED_PROTECTION )
2896
3140
GAME( 1997,  sdmg2,    0,       sdmg2,    sdmg2,    sdmg2,    ROT0, "IGS",              "Mahjong Super Da Man Guan II (China, V754C)", 0 )
2897
3141
GAME( 1997,  mgdh,     0,       mgdha,    mgdh,     mgdh,     ROT0, "IGS",              "Mahjong Man Guan Da Heng (Taiwan, V125T1)",   0 )
2898
3142
GAME( 1997,  mgdha,    mgdh,    mgdha,    mgdh ,    mgdha,    ROT0, "IGS",              "Mahjong Man Guan Da Heng (Taiwan, V123T1)",   0 )
2899
 
GAME( 1998,  mgcs,     0,       mgcs,     mgcs,     mgcs,     ROT0, "IGS",              "Mahjong Man Guan Cai Shen (V103CS)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
 
3143
GAME( 1998,  mgcs,     0,       mgcs,     mgcs,     mgcs,     ROT0, "IGS",              "Mahjong Man Guan Cai Shen (V103CS)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
2900
3144
GAME( 1998,  lhzb2,    0,       sdmg2,    sdmg2,    lhzb2,    ROT0, "IGS",              "Mahjong Long Hu Zheng Ba 2 (set 1)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
2901
3145
GAME( 1998,  lhzb2a,   lhzb2,   sdmg2,    sdmg2,    lhzb2a,   ROT0, "IGS",              "Mahjong Long Hu Zheng Ba 2 (set 2)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
2902
3146
GAME( 1998,  slqz2,    0,       sdmg2,    sdmg2,    slqz2,    ROT0, "IGS",              "Mahjong Shuang Long Qiang Zhu 2",             GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )