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);
483
482
// address lines swap (to do: collapse into one bitswap)
484
memcpy(tmp,rom,length);
485
for (i = 0;i < length;i++)
487
int addr = (i & ~0xff) | BITSWAP8(i,7,6,5,4,1,2,3,0);
491
memcpy(tmp,rom,length);
492
for (i = 0;i < length;i++)
494
int addr = (i & ~0xff) | BITSWAP8(i,7,6,5,2,4,3,1,0);
498
memcpy(tmp,rom,length);
499
for (i = 0;i < length;i++)
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);
506
static void tjsb_patch_rom(running_machine &machine)
508
UINT8 *rom = machine.region("maincpu")->base();
483
memcpy(tmp, rom, length);
484
for (i = 0; i < length; i++)
486
addr = (i & ~0xff) | BITSWAP8(i,7,6,5,4,1,2,3,0);
490
memcpy(tmp, rom, length);
491
for (i = 0; i < length; i++)
493
addr = (i & ~0xff) | BITSWAP8(i,7,6,5,2,4,3,1,0);
497
memcpy(tmp, rom, length);
498
for (i = 0; i < length; i++)
500
addr = (i & ~0xff) | BITSWAP8(i,7,6,5,3,4,2,1,0);
505
for (i = 0; i < length; i += 2)
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;
512
515
static DRIVER_INIT( tjsb )
514
517
decrypt_program_rom(machine, 0x05, 7, 6, 3, 2, 5, 4, 1, 0);
515
tjsb_patch_rom(machine);
517
519
tjsb_decrypt_sprites(machine);
1257
1273
logerror("PC %06X: irq2_enable = %04x\n",cpu_get_pc(&space->device()),data);
1260
static WRITE16_HANDLER( mgcs_paletteram_xRRRRRGGGGGBBBBB_w )
1276
static WRITE16_HANDLER( mgcs_paletteram_w )
1264
1278
COMBINE_DATA(&space->machine().generic.paletteram.u16[offset]);
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);
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);
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));
1274
1288
static ADDRESS_MAP_START( mgcs, AS_PROGRAM, 16 )
1513
1525
ADDRESS_MAP_END
1530
static WRITE8_HANDLER( tjsb_paletteram_w )
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];
1536
bgr = BITSWAP16(bgr, 15, 12,3,6,10,5, 4,2,9,13,8, 7,11,1,0,14);
1538
palette_set_color_rgb(space->machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
1541
static WRITE8_HANDLER( tjsb_output_w )
1543
igs017_state *state = space->machine().driver_data<igs017_state>();
1544
switch(state->m_input_select)
1547
coin_counter_w(space->machine(), 0, data & 0x80); // coin in
1548
if (!(data & ~0x80))
1553
coin_counter_w(space->machine(), 1, data & 0x01); // coin out
1554
if (!(data & ~0x01))
1559
space->machine().device<okim6295_device>("oki")->set_bank_base((data & 0x10) ? 0x40000 : 0); // oki bank (0x20/0x30)
1560
if (!(data & ~0x30))
1565
state->m_hopper = data & 0x40;
1566
if (!(data & ~0x40))
1570
logerror("%06x: warning, writing to igs_magic %02x = %02x\n", cpu_get_pc(&space->device()), state->m_input_select, data);
1573
static READ8_HANDLER( tjsb_input_r )
1575
igs017_state *state = space->machine().driver_data<igs017_state>();
1576
switch (state->m_input_select)
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");
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;
1588
logerror("PC %06X: input %02x read\n",cpu_get_pc(&space->device()),state->m_input_select);
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
1602
static ADDRESS_MAP_START( tjsb_io, AS_IO, 8 )
1603
AM_RANGE( 0x0000, 0x003f ) AM_RAM // internal regs
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
1609
// AM_RANGE(0x200a, 0x200a) AM_WRITENOP
1611
AM_RANGE( 0x2010, 0x2013 ) AM_DEVREAD("ppi8255", ppi8255_r)
1612
AM_RANGE( 0x2012, 0x2012 ) AM_WRITE( video_disable_w )
1614
AM_RANGE( 0x2014, 0x2014 ) AM_WRITE( nmi_enable_w )
1615
AM_RANGE( 0x2015, 0x2015 ) AM_WRITE( irq_enable_w )
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 )
1620
AM_RANGE( 0x9000, 0x9000 ) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
1622
AM_RANGE( 0xb000, 0xb001 ) AM_DEVWRITE( "ymsnd", ym2413_w )
1516
1626
/***************************************************************************
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)
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 )
1700
1810
PORT_START("KEY0")
1701
1811
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
2010
2120
INPUT_PORTS_END
2122
static INPUT_PORTS_START( tjsb )
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 ) )
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 ) )
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 ) )
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 )
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 )
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 )
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 )
2013
2220
/***************************************************************************
2014
2221
Graphics Layout
2308
2515
MACHINE_CONFIG_END
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)
2526
MCFG_PPI8255_ADD( "ppi8255", iqblocka_ppi8255_intf )
2528
MCFG_MACHINE_RESET(iqblocka)
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)
2539
MCFG_GFXDECODE(igs017)
2540
MCFG_PALETTE_LENGTH(0x100*2)
2542
MCFG_VIDEO_START(igs017)
2543
MCFG_VIDEO_RESET(igs017)
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)
2550
MCFG_OKIM6295_ADD("oki", XTAL_16MHz / 16, OKIM6295_PIN7_HIGH)
2551
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
2311
2555
/***************************************************************************
2313
2557
***************************************************************************/
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 )