diff options
author | 2016-12-11 01:05:15 +0100 | |
---|---|---|
committer | 2016-12-11 01:05:30 +0100 | |
commit | fbed00ead9ff1ef9ac80c92961a546ac796f0444 (patch) | |
tree | 8220528edfa02cf0a9e6d5e9293c3c98516c59b9 /src | |
parent | e23da89d4b49432ec7d80e58818eb08cfdfb8386 (diff) |
tnzs: Various refactoring. [Ryan Holtz]
Diffstat (limited to 'src')
-rw-r--r-- | src/mame/drivers/cchance.cpp | 21 | ||||
-rw-r--r-- | src/mame/drivers/tnzs.cpp | 451 | ||||
-rw-r--r-- | src/mame/includes/tnzs.h | 305 | ||||
-rw-r--r-- | src/mame/machine/tnzs.cpp | 258 | ||||
-rw-r--r-- | src/mame/video/tnzs.cpp | 11 |
5 files changed, 489 insertions, 557 deletions
diff --git a/src/mame/drivers/cchance.cpp b/src/mame/drivers/cchance.cpp index dddb53baa04..199631d4f04 100644 --- a/src/mame/drivers/cchance.cpp +++ b/src/mame/drivers/cchance.cpp @@ -39,19 +39,20 @@ cha3 $10d8 #include "includes/tnzs.h" #include "sound/ay8910.h" -class cchance_state : public tnzs_state +class cchance_state : public tnzs_base_state { public: cchance_state(const machine_config &mconfig, device_type type, const char *tag) - : tnzs_state(mconfig, type, tag) { } + : tnzs_base_state(mconfig, type, tag) { } + + void machine_reset() override; + void machine_start() override; uint8_t m_hop_io; uint8_t m_bell_io; DECLARE_WRITE8_MEMBER(output_0_w); DECLARE_READ8_MEMBER(input_1_r); DECLARE_WRITE8_MEMBER(output_1_w); - DECLARE_MACHINE_START(cchance); - DECLARE_MACHINE_RESET(cchance); }; @@ -191,18 +192,17 @@ static GFXDECODE_START( cchance ) GFXDECODE_ENTRY( "gfx1", 0, cchance_layout, 0x0, 32 ) GFXDECODE_END -MACHINE_START_MEMBER(cchance_state,cchance) +void cchance_state::machine_start() { save_item(NAME(m_hop_io)); save_item(NAME(m_bell_io)); } -MACHINE_RESET_MEMBER(cchance_state,cchance) +void cchance_state::machine_reset() { - m_mcu_type = -1; + tnzs_base_state::machine_reset(); m_hop_io = 0; m_bell_io = 0; - } static MACHINE_CONFIG_START( cchance, cchance_state ) @@ -211,9 +211,6 @@ static MACHINE_CONFIG_START( cchance, cchance_state ) MCFG_CPU_PROGRAM_MAP(main_map) MCFG_CPU_VBLANK_INT_DRIVER("screen", cchance_state, irq0_line_hold) - MCFG_MACHINE_START_OVERRIDE(cchance_state,cchance) - MCFG_MACHINE_RESET_OVERRIDE(cchance_state,cchance) - MCFG_GFXDECODE_ADD("gfxdecode", "palette", cchance) MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0) @@ -230,7 +227,7 @@ static MACHINE_CONFIG_START( cchance, cchance_state ) MCFG_SCREEN_PALETTE("palette") MCFG_PALETTE_ADD("palette", 512) - MCFG_PALETTE_INIT_OWNER(cchance_state,arknoid2) + MCFG_PALETTE_INIT_OWNER(tnzs_base_state, prompalette) MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/tnzs.cpp b/src/mame/drivers/tnzs.cpp index aab52b46744..f362fdf03b4 100644 --- a/src/mame/drivers/tnzs.cpp +++ b/src/mame/drivers/tnzs.cpp @@ -628,41 +628,30 @@ Driver by Takahiro Nogi (nogi@kt.rim.or.jp) 1999/11/06 #include "sound/volt_reg.h" #include "sound/ym2151.h" -SAMPLES_START_CB_MEMBER(tnzs_state::kageki_init_samples) +SAMPLES_START_CB_MEMBER(kageki_state::init_samples) { - uint8_t *scan, *src; - int16_t *dest; - int start, size; - int i, n; - - src = memregion("samples")->base() + 0x0090; - for (i = 0; i < MAX_SAMPLES; i++) + uint8_t *src = memregion("samples")->base() + 0x0090; + for (int i = 0; i < MAX_SAMPLES; i++) { - start = (src[(i * 2) + 1] * 256) + src[(i * 2)]; - scan = &src[start]; - size = 0; + int start = (src[(i * 2) + 1] * 256) + src[(i * 2)]; + uint8_t *scan = &src[start]; + int size = 0; // check sample length - while (1) - { - if (*scan++ == 0x00) - break; - else - size++; - } + while (*scan++ != 0x00) + size++; /* 2009-11 FP: should these be saved? */ m_sampledata[i] = std::make_unique<int16_t[]>(size); m_samplesize[i] = size; - if (start < 0x100) start = size = 0; // signed 8-bit sample to unsigned 8-bit sample convert - dest = m_sampledata[i].get(); + int16_t *dest = m_sampledata[i].get(); scan = &src[start]; - for (n = 0; n < size; n++) + for (int n = 0; n < size; n++) { *dest++ = (int8_t)((*scan++) ^ 0x80) * 256; } @@ -671,14 +660,14 @@ SAMPLES_START_CB_MEMBER(tnzs_state::kageki_init_samples) } -READ8_MEMBER(tnzs_state::kageki_csport_r) +READ8_MEMBER(kageki_state::csport_r) { int dsw, dsw1, dsw2; dsw1 = m_dswa->read(); dsw2 = m_dswb->read(); - switch (m_kageki_csport_sel) + switch (m_csport_sel) { case 0x00: // DSW2 5,1 / DSW1 5,1 dsw = (((dsw2 & 0x10) >> 1) | ((dsw2 & 0x01) << 2) | ((dsw1 & 0x10) >> 3) | ((dsw1 & 0x01) >> 0)); @@ -694,20 +683,20 @@ READ8_MEMBER(tnzs_state::kageki_csport_r) break; default: dsw = 0x00; - // logerror("kageki_csport_sel error !! (0x%08X)\n", m_kageki_csport_sel); + // logerror("csport_sel error !! (0x%08X)\n", m_csport_sel); } return (dsw & 0xff); } -WRITE8_MEMBER(tnzs_state::kageki_csport_w) +WRITE8_MEMBER(kageki_state::csport_w) { char mess[80]; if (data > 0x3f) { // read dipsw port - m_kageki_csport_sel = (data & 0x03); + m_csport_sel = (data & 0x03); } else { @@ -727,14 +716,7 @@ WRITE8_MEMBER(tnzs_state::kageki_csport_w) } } -WRITE8_MEMBER(tnzs_state::kabukiz_sound_bank_w) -{ - // to avoid the write when the sound chip is initialized - if (data != 0xff) - m_audiobank->set_entry(data & 0x07); -} - -static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tnzs_base_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_DEVICE("mainbank", address_map_bank_device, amap8) AM_RANGE(0xc000, 0xcfff) AM_RAM AM_DEVREADWRITE("spritegen", seta001_device, spritecodelow_r8, spritecodelow_w8) @@ -743,14 +725,18 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tnzs_state ) AM_RANGE(0xf000, 0xf2ff) AM_RAM AM_DEVREADWRITE("spritegen", seta001_device, spriteylow_r8, spriteylow_w8) AM_RANGE(0xf300, 0xf303) AM_MIRROR(0xfc) AM_DEVWRITE("spritegen", seta001_device, spritectrl_w8) /* control registers (0x80 mirror used by Arkanoid 2) */ AM_RANGE(0xf400, 0xf400) AM_DEVWRITE("spritegen", seta001_device, spritebgflag_w8) /* enable / disable background transparency */ - AM_RANGE(0xf600, 0xf600) AM_READNOP AM_WRITE(tnzs_ramrom_bankswitch_w) + AM_RANGE(0xf600, 0xf600) AM_READNOP AM_WRITE(ramrom_bankswitch_w) + AM_RANGE(0xf800, 0xfbff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") +ADDRESS_MAP_END + +static ADDRESS_MAP_START( prompal_main_map, AS_PROGRAM, 8, extrmatn_state ) /* arknoid2, extrmatn, plumppop and drtoppel have PROMs instead of RAM */ /* drtoppel writes here anyway! (maybe leftover from tests during development) */ - /* so the handler is patched out in init_drtopple() */ - AM_RANGE(0xf800, 0xfbff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") + AM_RANGE(0xf800, 0xfbff) AM_WRITENOP + AM_IMPORT_FROM(main_map) ADDRESS_MAP_END -static ADDRESS_MAP_START( cpu0_type2, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( tnzsb_main_map, AS_PROGRAM, 8, tnzsb_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_DEVICE("mainbank", address_map_bank_device, amap8) AM_RANGE(0xc000, 0xcfff) AM_RAM AM_DEVREADWRITE("spritegen", seta001_device, spritecodelow_r8, spritecodelow_w8) @@ -759,112 +745,100 @@ static ADDRESS_MAP_START( cpu0_type2, AS_PROGRAM, 8, tnzs_state ) AM_RANGE(0xf000, 0xf2ff) AM_RAM AM_DEVREADWRITE("spritegen", seta001_device, spriteylow_r8, spriteylow_w8) AM_RANGE(0xf300, 0xf303) AM_MIRROR(0xfc) AM_DEVWRITE("spritegen", seta001_device, spritectrl_w8) /* control registers (0x80 mirror used by Arkanoid 2) */ AM_RANGE(0xf400, 0xf400) AM_DEVWRITE("spritegen", seta001_device, spritebgflag_w8) /* enable / disable background transparency */ - AM_RANGE(0xf600, 0xf600) AM_WRITE(tnzs_ramrom_bankswitch_w) + AM_RANGE(0xf600, 0xf600) AM_WRITE(ramrom_bankswitch_w) /* kabukiz still writes here but it's not used (it's paletteram in type1 map) */ AM_RANGE(0xf800, 0xfbff) AM_WRITENOP ADDRESS_MAP_END - -static ADDRESS_MAP_START( sub_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( base_sub_map, AS_PROGRAM, 8, tnzs_base_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("subbank") - AM_RANGE(0xa000, 0xa000) AM_WRITE(tnzs_bankswitch1_w) + AM_RANGE(0xa000, 0xa000) AM_WRITE(bankswitch1_w) AM_RANGE(0xb000, 0xb001) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write) - AM_RANGE(0xc000, 0xc001) AM_READWRITE(mcu_r, mcu_w) /* not present in insectx */ AM_RANGE(0xd000, 0xdfff) AM_RAM AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1") - AM_RANGE(0xf000, 0xf003) AM_READ(arknoid2_sh_f000_r) /* paddles in arkanoid2/plumppop. The ports are */ - /* read but not used by the other games, and are not read at */ - /* all by insectx. */ ADDRESS_MAP_END -static ADDRESS_MAP_START( arknoid2_sub_map, AS_PROGRAM, 8, tnzs_state ) - AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("subbank") - AM_RANGE(0xa000, 0xa000) AM_WRITE(arknoid2_mcu_reset_w) - AM_RANGE(0xb000, 0xb001) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write) - AM_RANGE(0xc000, 0xc001) AM_READWRITE(arknoid2_mcu_r, arknoid2_mcu_w) - AM_RANGE(0xd000, 0xdfff) AM_RAM - AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1") - AM_RANGE(0xf000, 0xf003) AM_READ(arknoid2_sh_f000_r) /* paddles in arkanoid2/plumppop. The ports are */ +static ADDRESS_MAP_START( tnzs_sub_map, AS_PROGRAM, 8, tnzs_mcu_state ) + AM_RANGE(0xc000, 0xc001) AM_READWRITE(mcu_r, mcu_w) /* not present in insectx */ + AM_RANGE(0xa000, 0xa000) AM_WRITE(bankswitch1_w) + AM_RANGE(0xf000, 0xf003) AM_READ(analog_r) /* paddles in arkanoid2/plumppop. The ports are */ + /* read but not used by the other games, and are not read at */ + /* all by insectx. */ + AM_IMPORT_FROM(base_sub_map) ADDRESS_MAP_END -static ADDRESS_MAP_START( kageki_sub_map, AS_PROGRAM, 8, tnzs_state ) - AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("subbank") - AM_RANGE(0xa000, 0xa000) AM_WRITE(tnzs_bankswitch1_w) - AM_RANGE(0xb000, 0xb001) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write) +static ADDRESS_MAP_START( arknoid2_sub_map, AS_PROGRAM, 8, arknoid2_state ) + AM_RANGE(0xc000, 0xc001) AM_READWRITE(mcu_r, mcu_w) + AM_IMPORT_FROM(tnzs_sub_map) +ADDRESS_MAP_END + +static ADDRESS_MAP_START( kageki_sub_map, AS_PROGRAM, 8, kageki_state ) AM_RANGE(0xc000, 0xc000) AM_READ_PORT("IN0") AM_RANGE(0xc001, 0xc001) AM_READ_PORT("IN1") AM_RANGE(0xc002, 0xc002) AM_READ_PORT("IN2") - AM_RANGE(0xd000, 0xdfff) AM_RAM - AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1") + AM_IMPORT_FROM(base_sub_map) ADDRESS_MAP_END -/* the later board is different, it has a third CPU (and of course no mcu) */ +static ADDRESS_MAP_START( insectx_sub_map, AS_PROGRAM, 8, insectx_state ) + AM_RANGE(0xc000, 0xc000) AM_READ_PORT("IN0") + AM_RANGE(0xc001, 0xc001) AM_READ_PORT("IN1") + AM_RANGE(0xc002, 0xc002) AM_READ_PORT("IN2") + AM_IMPORT_FROM(base_sub_map) +ADDRESS_MAP_END -WRITE8_MEMBER(tnzs_state::tnzsb_sound_command_w) -{ - m_soundlatch->write(space, offset, data); - m_audiocpu->set_input_line_and_vector(0, HOLD_LINE, 0xff); -} +/* the later board is different, it has a third CPU (and of course no mcu) */ -static ADDRESS_MAP_START( tnzsb_cpu1_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( tnzsb_base_sub_map, AS_PROGRAM, 8, tnzsb_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("subbank") - AM_RANGE(0xa000, 0xa000) AM_WRITE(tnzs_bankswitch1_w) + AM_RANGE(0xa000, 0xa000) AM_WRITE(bankswitch1_w) AM_RANGE(0xb002, 0xb002) AM_READ_PORT("DSWA") AM_RANGE(0xb003, 0xb003) AM_READ_PORT("DSWB") - AM_RANGE(0xb004, 0xb004) AM_WRITE(tnzsb_sound_command_w) + AM_RANGE(0xb004, 0xb004) AM_WRITE(sound_command_w) AM_RANGE(0xc000, 0xc000) AM_READ_PORT("IN0") AM_RANGE(0xc001, 0xc001) AM_READ_PORT("IN1") AM_RANGE(0xc002, 0xc002) AM_READ_PORT("IN2") AM_RANGE(0xd000, 0xdfff) AM_RAM AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1") +ADDRESS_MAP_END + +static ADDRESS_MAP_START( tnzsb_sub_map, AS_PROGRAM, 8, tnzsb_state ) AM_RANGE(0xf000, 0xf003) AM_READONLY AM_RANGE(0xf000, 0xf3ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") + AM_IMPORT_FROM(tnzsb_base_sub_map) ADDRESS_MAP_END -static ADDRESS_MAP_START( kabukiz_cpu1_map, AS_PROGRAM, 8, tnzs_state ) - AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("subbank") - AM_RANGE(0xa000, 0xa000) AM_WRITE(tnzs_bankswitch1_w) - AM_RANGE(0xb002, 0xb002) AM_READ_PORT("DSWA") - AM_RANGE(0xb003, 0xb003) AM_READ_PORT("DSWB") - AM_RANGE(0xb004, 0xb004) AM_WRITE(tnzsb_sound_command_w) - AM_RANGE(0xc000, 0xc000) AM_READ_PORT("IN0") - AM_RANGE(0xc001, 0xc001) AM_READ_PORT("IN1") - AM_RANGE(0xc002, 0xc002) AM_READ_PORT("IN2") - AM_RANGE(0xd000, 0xdfff) AM_RAM - AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1") +static ADDRESS_MAP_START( kabukiz_sub_map, AS_PROGRAM, 8, kabukiz_state ) AM_RANGE(0xf800, 0xfbff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") + AM_IMPORT_FROM(tnzsb_base_sub_map) ADDRESS_MAP_END -static ADDRESS_MAP_START( tnzsb_cpu2_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( tnzsb_cpu2_map, AS_PROGRAM, 8, tnzsb_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0xc000, 0xdfff) AM_RAM ADDRESS_MAP_END -static ADDRESS_MAP_START( kabukiz_cpu2_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( kabukiz_cpu2_map, AS_PROGRAM, 8, kabukiz_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("audiobank") AM_RANGE(0xe000, 0xffff) AM_RAM ADDRESS_MAP_END -static ADDRESS_MAP_START( tnzsb_io_map, AS_IO, 8, tnzs_state ) +static ADDRESS_MAP_START( tnzsb_io_map, AS_IO, 8, tnzsb_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write) AM_RANGE(0x02, 0x02) AM_DEVREAD("soundlatch", generic_latch_8_device, read) ADDRESS_MAP_END -static ADDRESS_MAP_START( i8742_map, AS_IO, 8, tnzs_state ) +static ADDRESS_MAP_START( i8742_map, AS_IO, 8, tnzs_mcu_state ) AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READ(mcu_port1_r) AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(mcu_port2_r, mcu_port2_w) AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ_PORT("COIN1") AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ_PORT("COIN2") ADDRESS_MAP_END -static ADDRESS_MAP_START( jpopnics_main_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( jpopnics_main_map, AS_PROGRAM, 8, jpopnics_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_DEVICE("mainbank", address_map_bank_device, amap8) AM_RANGE(0xc000, 0xcfff) AM_RAM AM_DEVREADWRITE("spritegen", seta001_device, spritecodelow_r8, spritecodelow_w8) @@ -873,21 +847,15 @@ static ADDRESS_MAP_START( jpopnics_main_map, AS_PROGRAM, 8, tnzs_state ) AM_RANGE(0xf000, 0xf2ff) AM_RAM AM_DEVREADWRITE("spritegen", seta001_device, spriteylow_r8, spriteylow_w8) AM_RANGE(0xf300, 0xf303) AM_MIRROR(0xfc) AM_DEVWRITE("spritegen", seta001_device, spritectrl_w8) /* control registers (0x80 mirror used by Arkanoid 2) */ AM_RANGE(0xf400, 0xf400) AM_DEVWRITE("spritegen", seta001_device, spritebgflag_w8) /* enable / disable background transparency */ - AM_RANGE(0xf600, 0xf600) AM_READNOP AM_WRITE(tnzs_ramrom_bankswitch_w) + AM_RANGE(0xf600, 0xf600) AM_READNOP AM_WRITE(ramrom_bankswitch_w) AM_RANGE(0xf800, 0xffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") ADDRESS_MAP_END -WRITE8_MEMBER(tnzs_state::jpopnics_subbankswitch_w) -{ - /* bits 0-1 select ROM bank */ - m_subbank->set_entry(data & 0x03); -} - -static ADDRESS_MAP_START( jpopnics_sub_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( jpopnics_sub_map, AS_PROGRAM, 8, jpopnics_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("subbank") - AM_RANGE(0xa000, 0xa000) AM_WRITE(jpopnics_subbankswitch_w) + AM_RANGE(0xa000, 0xa000) AM_WRITE(subbankswitch_w) AM_RANGE(0xb000, 0xb001) AM_DEVREADWRITE("ymsnd", ym2151_device, read, write) AM_RANGE(0xc000, 0xc000) AM_READ_PORT("IN1") AM_RANGE(0xc001, 0xc001) AM_READ_PORT("IN2") @@ -897,11 +865,11 @@ static ADDRESS_MAP_START( jpopnics_sub_map, AS_PROGRAM, 8, tnzs_state ) AM_RANGE(0xd000, 0xdfff) AM_RAM AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1") - AM_RANGE(0xf000, 0xf003) AM_READ(arknoid2_sh_f000_r) + AM_RANGE(0xf000, 0xf003) AM_READ(analog_r) ADDRESS_MAP_END /* RAM/ROM bank that maps at 0x8000-0xbfff on maincpu */ -static ADDRESS_MAP_START( mainbank_map, AS_PROGRAM, 8, tnzs_state ) +static ADDRESS_MAP_START( mainbank_map, AS_PROGRAM, 8, tnzs_base_state ) AM_RANGE(0x00000, 0x07fff) AM_RAM // instead of the first two banks of ROM being repeated redundantly the hardware maps RAM here AM_RANGE(0x08000, 0x1ffff) AM_ROM AM_REGION(":maincpu", 0x8000) ADDRESS_MAP_END @@ -1541,44 +1509,31 @@ static GFXDECODE_START( insectx ) GFXDECODE_ENTRY( "gfx1", 0, insectx_charlayout, 0, 32 ) GFXDECODE_END - -/* handler called by the 2203 emulator when the internal timers cause an IRQ */ -WRITE_LINE_MEMBER(tnzs_state::irqhandler) -{ - m_audiocpu->set_input_line(INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); -} - -static MACHINE_CONFIG_START( tnzs, tnzs_state ) +static MACHINE_CONFIG_START( tnzs_base, tnzs_base_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80,XTAL_12MHz/2) /* 6.0 MHz ??? - Main board Crystal is 12MHz */ + MCFG_CPU_ADD("maincpu", Z80,XTAL_12MHz/2) /* 6.0 MHz ??? - Main board Crystal is 12MHz, verified on insectx, kageki, tnzsb */ MCFG_CPU_PROGRAM_MAP(main_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) + MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_base_state, irq0_line_hold) - MCFG_CPU_ADD("sub", Z80,XTAL_12MHz/2) /* 6.0 MHz ??? - Main board Crystal is 12MHz */ - MCFG_CPU_PROGRAM_MAP(sub_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - - MCFG_CPU_ADD("mcu", I8742, 12000000/2) /* 400KHz ??? - Main board Crystal is 12MHz */ - MCFG_CPU_IO_MAP(i8742_map) + MCFG_CPU_ADD("sub", Z80,XTAL_12MHz/2) /* 6.0 MHz ??? - Main board Crystal is 12MHz, verified on insectx, kageki, tnzsb */ + MCFG_CPU_PROGRAM_MAP(base_sub_map) + MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_base_state, irq0_line_hold) MCFG_FRAGMENT_ADD(tnzs_mainbank) MCFG_QUANTUM_PERFECT_CPU("maincpu") - MCFG_MACHINE_START_OVERRIDE(tnzs_state,tnzs) - MCFG_MACHINE_RESET_OVERRIDE(tnzs_state,tnzs) - + /* video hardware */ MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0) MCFG_SETA001_SPRITE_GFXDECODE("gfxdecode") - /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(59.15) /* it should be the same as the newer pcb vsync */ - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) + MCFG_SCREEN_REFRESH_RATE(60) + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MCFG_SCREEN_UPDATE_DRIVER(tnzs_state, screen_update_tnzs) - MCFG_SCREEN_VBLANK_DRIVER(tnzs_state, screen_eof_tnzs) + MCFG_SCREEN_UPDATE_DRIVER(tnzs_base_state, screen_update_tnzs) + MCFG_SCREEN_VBLANK_DRIVER(tnzs_base_state, screen_eof_tnzs) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", tnzs) @@ -1587,71 +1542,62 @@ static MACHINE_CONFIG_START( tnzs, tnzs_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("speaker") +MACHINE_CONFIG_END + +static MACHINE_CONFIG_DERIVED_CLASS( tnzs, tnzs_base, tnzs_state ) + MCFG_CPU_ADD("mcu", I8742, 12000000/2) /* 400KHz ??? - Main board Crystal is 12MHz */ + MCFG_CPU_IO_MAP(i8742_map) + + MCFG_CPU_MODIFY("sub") + MCFG_CPU_PROGRAM_MAP(tnzs_sub_map) + /* video hardware */ + MCFG_SCREEN_MODIFY("screen") + MCFG_SCREEN_REFRESH_RATE(59.15) /* it should be the same as the newer pcb vsync */ + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) + + /* sound hardware */ MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/4) MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSWA")) MCFG_AY8910_PORT_B_READ_CB(IOPORT("DSWB")) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 0.3) MACHINE_CONFIG_END -static MACHINE_CONFIG_DERIVED( extrmatn, tnzs ) +static MACHINE_CONFIG_DERIVED_CLASS( extrmatn, tnzs, extrmatn_state ) + /* basic machine hardware */ + MCFG_CPU_MODIFY("maincpu") + MCFG_CPU_PROGRAM_MAP(prompal_main_map) + + /* video hardware */ + MCFG_SCREEN_MODIFY("screen") + MCFG_SCREEN_REFRESH_RATE(60) + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) + MCFG_PALETTE_MODIFY("palette") - MCFG_PALETTE_INIT_OWNER(tnzs_state,arknoid2) + MCFG_PALETTE_INIT_OWNER(tnzs_base_state, prompalette) MACHINE_CONFIG_END -static MACHINE_CONFIG_DERIVED( arknoid2, tnzs ) +static MACHINE_CONFIG_DERIVED_CLASS( arknoid2, extrmatn, arknoid2_state ) /* basic machine hardware */ MCFG_CPU_MODIFY("maincpu") - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, arknoid2_interrupt) + MCFG_CPU_VBLANK_INT_DRIVER("screen", arknoid2_state, mcu_interrupt) MCFG_CPU_MODIFY("sub") MCFG_CPU_PROGRAM_MAP(arknoid2_sub_map) MCFG_CPU_MODIFY("mcu") MCFG_DEVICE_DISABLE() - - MCFG_PALETTE_MODIFY("palette") - MCFG_PALETTE_INIT_OWNER(tnzs_state,arknoid2) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( insectx, tnzs_state ) - +static MACHINE_CONFIG_DERIVED_CLASS( insectx, tnzs_base, insectx_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, XTAL_12MHz/2) /* verified on pcb */ - MCFG_CPU_PROGRAM_MAP(main_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - - MCFG_CPU_ADD("sub", Z80, XTAL_12MHz/2) /* verified on pcb */ - MCFG_CPU_PROGRAM_MAP(sub_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - - MCFG_FRAGMENT_ADD(tnzs_mainbank) - - MCFG_QUANTUM_PERFECT_CPU("maincpu") - - MCFG_MACHINE_START_OVERRIDE(tnzs_state,tnzs) - MCFG_MACHINE_RESET_OVERRIDE(tnzs_state,tnzs) - - MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0) - MCFG_SETA001_SPRITE_GFXDECODE("gfxdecode") + MCFG_CPU_MODIFY("sub") + MCFG_CPU_PROGRAM_MAP(insectx_sub_map) /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MCFG_SCREEN_UPDATE_DRIVER(tnzs_state, screen_update_tnzs) - MCFG_SCREEN_VBLANK_DRIVER(tnzs_state, screen_eof_tnzs) - MCFG_SCREEN_PALETTE("palette") - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", insectx) - MCFG_PALETTE_ADD("palette", 512) - MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) + MCFG_GFXDECODE_MODIFY("gfxdecode", insectx) /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("speaker") - MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/4) /* verified on pcb */ MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSWA")) MCFG_AY8910_PORT_B_READ_CB(IOPORT("DSWB")) @@ -1659,47 +1605,15 @@ static MACHINE_CONFIG_START( insectx, tnzs_state ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( kageki, tnzs_state ) - +static MACHINE_CONFIG_DERIVED_CLASS( kageki, tnzs_base, kageki_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, XTAL_12MHz/2) /* verified on pcb */ - MCFG_CPU_PROGRAM_MAP(main_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - - MCFG_CPU_ADD("sub", Z80, XTAL_12MHz/2) /* verified on pcb */ + MCFG_CPU_MODIFY("sub") MCFG_CPU_PROGRAM_MAP(kageki_sub_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - - MCFG_FRAGMENT_ADD(tnzs_mainbank) - - MCFG_QUANTUM_PERFECT_CPU("maincpu") - - MCFG_MACHINE_START_OVERRIDE(tnzs_state,tnzs) - MCFG_MACHINE_RESET_OVERRIDE(tnzs_state,tnzs) - - MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0) - MCFG_SETA001_SPRITE_GFXDECODE("gfxdecode") - - /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MCFG_SCREEN_UPDATE_DRIVER(tnzs_state, screen_update_tnzs) - MCFG_SCREEN_VBLANK_DRIVER(tnzs_state, screen_eof_tnzs) - MCFG_SCREEN_PALETTE("palette") - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", tnzs) - MCFG_PALETTE_ADD("palette", 512) - MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("speaker") - MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/4) /* verified on pcb */ - MCFG_AY8910_PORT_A_READ_CB(READ8(tnzs_state, kageki_csport_r)) - MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(tnzs_state, kageki_csport_w)) + MCFG_AY8910_PORT_A_READ_CB(READ8(kageki_state, csport_r)) + MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(kageki_state, csport_w)) MCFG_SOUND_ROUTE(0, "speaker", 0.15) MCFG_SOUND_ROUTE(1, "speaker", 0.15) MCFG_SOUND_ROUTE(2, "speaker", 0.15) @@ -1707,57 +1621,31 @@ static MACHINE_CONFIG_START( kageki, tnzs_state ) MCFG_SOUND_ADD("samples", SAMPLES, 0) MCFG_SAMPLES_CHANNELS(1) - MCFG_SAMPLES_START_CB(tnzs_state, kageki_init_samples) + MCFG_SAMPLES_START_CB(kageki_state, init_samples) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 1.0) MACHINE_CONFIG_END - -static MACHINE_CONFIG_START( tnzsb, tnzs_state ) - +static MACHINE_CONFIG_DERIVED_CLASS( tnzsb, tnzs_base, tnzsb_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, XTAL_12MHz/2) /* verified on pcb */ - MCFG_CPU_PROGRAM_MAP(cpu0_type2) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) + MCFG_CPU_MODIFY("maincpu") + MCFG_CPU_PROGRAM_MAP(tnzsb_main_map) - MCFG_CPU_ADD("sub", Z80, XTAL_12MHz/2) /* verified on pcb */ - MCFG_CPU_PROGRAM_MAP(tnzsb_cpu1_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) + MCFG_CPU_MODIFY("sub") /* verified on pcb */ + MCFG_CPU_PROGRAM_MAP(tnzsb_sub_map) MCFG_CPU_ADD("audiocpu", Z80, XTAL_12MHz/2) /* verified on pcb */ MCFG_CPU_PROGRAM_MAP(tnzsb_cpu2_map) MCFG_CPU_IO_MAP(tnzsb_io_map) - MCFG_FRAGMENT_ADD(tnzs_mainbank) - - MCFG_QUANTUM_PERFECT_CPU("maincpu") - - MCFG_MACHINE_START_OVERRIDE(tnzs_state,tnzs) - MCFG_MACHINE_RESET_OVERRIDE(tnzs_state,tnzs) - - MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0) - MCFG_SETA001_SPRITE_GFXDECODE("gfxdecode") - /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) + MCFG_SCREEN_MODIFY("screen") MCFG_SCREEN_REFRESH_RATE(59.15) /* verified on pcb */ - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MCFG_SCREEN_UPDATE_DRIVER(tnzs_state, screen_update_tnzs) - MCFG_SCREEN_VBLANK_DRIVER(tnzs_state, screen_eof_tnzs) - MCFG_SCREEN_PALETTE("palette") - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", tnzs) - MCFG_PALETTE_ADD("palette", 512) - MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("speaker") - MCFG_GENERIC_LATCH_8_ADD("soundlatch") MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/4) /* verified on pcb */ - MCFG_YM2203_IRQ_HANDLER(WRITELINE(tnzs_state, irqhandler)) + MCFG_YM2203_IRQ_HANDLER(WRITELINE(tnzsb_state, ym2203_irqhandler)) MCFG_SOUND_ROUTE(0, "speaker", 1.0) MCFG_SOUND_ROUTE(1, "speaker", 1.0) MCFG_SOUND_ROUTE(2, "speaker", 1.0) @@ -1765,17 +1653,18 @@ static MACHINE_CONFIG_START( tnzsb, tnzs_state ) MACHINE_CONFIG_END -static MACHINE_CONFIG_DERIVED( kabukiz, tnzsb ) +static MACHINE_CONFIG_DERIVED_CLASS( kabukiz, tnzsb, kabukiz_state ) /* basic machine hardware */ MCFG_CPU_MODIFY("sub") - MCFG_CPU_PROGRAM_MAP(kabukiz_cpu1_map) + MCFG_CPU_PROGRAM_MAP(kabukiz_sub_map) MCFG_CPU_MODIFY("audiocpu") MCFG_CPU_PROGRAM_MAP(kabukiz_cpu2_map) + /* sound hardware */ MCFG_SOUND_MODIFY("ymsnd") - MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(tnzs_state, kabukiz_sound_bank_w)) + MCFG_AY8910_PORT_A_WRITE_CB(WRITE8(kabukiz_state, sound_bank_w)) MCFG_AY8910_PORT_B_WRITE_CB(DEVWRITE8("dac", dac_byte_interface, write)) MCFG_SOUND_ADD("dac", DAC_8BIT_R2R, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 0.5) // unknown DAC @@ -1784,45 +1673,21 @@ static MACHINE_CONFIG_DERIVED( kabukiz, tnzsb ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( jpopnics, tnzs_state ) - +static MACHINE_CONFIG_DERIVED_CLASS( jpopnics, tnzs_base, jpopnics_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80,XTAL_12MHz/2) /* Not verified - Main board Crystal is 12MHz */ + MCFG_CPU_MODIFY("maincpu") MCFG_CPU_PROGRAM_MAP(jpopnics_main_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - MCFG_CPU_ADD("sub", Z80,XTAL_12MHz/2) /* Not verified - Main board Crystal is 12MHz */ + MCFG_CPU_MODIFY("sub") MCFG_CPU_PROGRAM_MAP(jpopnics_sub_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", tnzs_state, irq0_line_hold) - - MCFG_FRAGMENT_ADD(tnzs_mainbank) - - MCFG_QUANTUM_PERFECT_CPU("maincpu") - - MCFG_MACHINE_START_OVERRIDE(tnzs_state,tnzs_common) - MCFG_MACHINE_RESET_OVERRIDE(tnzs_state,jpopnics) - - MCFG_DEVICE_ADD("spritegen", SETA001_SPRITE, 0) - MCFG_SETA001_SPRITE_GFXDECODE("gfxdecode") /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MCFG_SCREEN_UPDATE_DRIVER(tnzs_state, screen_update_tnzs) - MCFG_SCREEN_VBLANK_DRIVER(tnzs_state, screen_eof_tnzs) - MCFG_SCREEN_PALETTE("palette") - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", tnzs) - MCFG_PALETTE_ADD("palette", 1024) + MCFG_PALETTE_MODIFY("palette") + MCFG_PALETTE_ENTRIES(1024) MCFG_PALETTE_FORMAT(GGGGBBBBRRRRxxxx) /* wrong, the other 4 bits seem to be used as well */ MCFG_PALETTE_ENDIANNESS(ENDIANNESS_BIG) /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("speaker") - MCFG_YM2151_ADD("ymsnd", XTAL_12MHz/4) /* Not verified - Main board Crystal is 12MHz */ MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 0.3) MACHINE_CONFIG_END @@ -2672,40 +2537,40 @@ ROM_END // YEAR, NAME, PARENT, MACHINE, INPUT, INIT, MONITOR,COMPANY,FULLNAME,FLAGS -GAME( 1987, plumppop, 0, extrmatn, plumppop, tnzs_state, plumpop, ROT0, "Taito Corporation", "Plump Pop (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, plumppop, 0, extrmatn, plumppop, driver_device, 0, ROT0, "Taito Corporation", "Plump Pop (Japan)", MACHINE_SUPPORTS_SAVE ) GAME( 1992, jpopnics, 0, jpopnics, jpopnics, driver_device, 0, ROT0, "Nics", "Jumping Pop (Nics, Korean hack of Plump Pop)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1987, extrmatn, 0, extrmatn, extrmatn, tnzs_state, extrmatn, ROT270, "Taito Corporation Japan", "Extermination (World)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, extrmatnu, extrmatn, extrmatn, extrmatn, tnzs_state, extrmatn, ROT270, "Taito (World Games license)", "Extermination (US, World Games)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, extrmatnur,extrmatn, extrmatn, extrmatn, tnzs_state, extrmatn, ROT270, "Taito America Corporation (Romstar license)", "Extermination (US, Romstar)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, extrmatnj, extrmatn, extrmatn, extrmatn, tnzs_state, extrmatn, ROT270, "Taito Corporation", "Extermination (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, extrmatn, 0, extrmatn, extrmatn, driver_device, 0, ROT270, "Taito Corporation Japan", "Extermination (World)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, extrmatnu, extrmatn, extrmatn, extrmatn, driver_device, 0, ROT270, "Taito (World Games license)", "Extermination (US, World Games)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, extrmatnur,extrmatn, extrmatn, extrmatn, driver_device, 0, ROT270, "Taito America Corporation (Romstar license)", "Extermination (US, Romstar)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, extrmatnj, extrmatn, extrmatn, extrmatn, driver_device, 0, ROT270, "Taito Corporation", "Extermination (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, arknoid2, 0, arknoid2, arknoid2, tnzs_state, arknoid2, ROT270, "Taito Corporation Japan", "Arkanoid - Revenge of DOH (World)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, arknoid2u, arknoid2, arknoid2, arknid2u, tnzs_state, arknoid2, ROT270, "Taito America Corporation (Romstar license)", "Arkanoid - Revenge of DOH (US)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, arknoid2j, arknoid2, arknoid2, arknid2u, tnzs_state, arknoid2, ROT270, "Taito Corporation", "Arkanoid - Revenge of DOH (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, arknoid2b, arknoid2, arknoid2, arknid2u, tnzs_state, arknoid2, ROT270, "bootleg", "Arkanoid - Revenge of DOH (Japan bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, arknoid2, 0, arknoid2, arknoid2, driver_device, 0, ROT270, "Taito Corporation Japan", "Arkanoid - Revenge of DOH (World)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, arknoid2u, arknoid2, arknoid2, arknid2u, driver_device, 0, ROT270, "Taito America Corporation (Romstar license)", "Arkanoid - Revenge of DOH (US)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, arknoid2j, arknoid2, arknoid2, arknid2u, driver_device, 0, ROT270, "Taito Corporation", "Arkanoid - Revenge of DOH (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, arknoid2b, arknoid2, arknoid2, arknid2u, driver_device, 0, ROT270, "bootleg", "Arkanoid - Revenge of DOH (Japan bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, drtoppel, 0, extrmatn, drtoppel, tnzs_state, drtoppel, ROT90, "Kaneko / Taito Corporation Japan", "Dr. Toppel's Adventure (World)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ -GAME( 1987, drtoppelu, drtoppel, extrmatn, drtopplu, tnzs_state, drtoppel, ROT90, "Kaneko / Taito America Corporation", "Dr. Toppel's Adventure (US)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ -GAME( 1987, drtoppelj, drtoppel, extrmatn, drtopplu, tnzs_state, drtoppel, ROT90, "Kaneko / Taito Corporation", "Dr. Toppel's Tankentai (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, drtoppel, 0, extrmatn, drtoppel, driver_device, 0, ROT90, "Kaneko / Taito Corporation Japan", "Dr. Toppel's Adventure (World)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ +GAME( 1987, drtoppelu, drtoppel, extrmatn, drtopplu, driver_device, 0, ROT90, "Kaneko / Taito America Corporation", "Dr. Toppel's Adventure (US)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ +GAME( 1987, drtoppelj, drtoppel, extrmatn, drtopplu, driver_device, 0, ROT90, "Kaneko / Taito Corporation", "Dr. Toppel's Tankentai (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, kageki, 0, kageki, kageki, tnzs_state, kageki, ROT90, "Kaneko / Taito America Corporation (Romstar license)", "Kageki (US)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, kagekij, kageki, kageki, kagekij, tnzs_state, kageki, ROT90, "Kaneko / Taito Corporation", "Kageki (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, kagekih, kageki, kageki, kageki, tnzs_state, kageki, ROT90, "hack", "Kageki (hack)", MACHINE_SUPPORTS_SAVE ) // date is hacked at least, might also be a Japan set hacked to show english +GAME( 1988, kageki, 0, kageki, kageki, driver_device, 0, ROT90, "Kaneko / Taito America Corporation (Romstar license)", "Kageki (US)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, kagekij, kageki, kageki, kagekij, driver_device, 0, ROT90, "Kaneko / Taito Corporation", "Kageki (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, kagekih, kageki, kageki, kageki, driver_device, 0, ROT90, "hack", "Kageki (hack)", MACHINE_SUPPORTS_SAVE ) // date is hacked at least, might also be a Japan set hacked to show english -GAME( 1988, chukatai, 0, tnzs, chukatai, tnzs_state, chukatai, ROT0, "Taito Corporation Japan", "Chuka Taisen (World)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ -GAME( 1988, chukataiu, chukatai, tnzs, chukatau, tnzs_state, chukatai, ROT0, "Taito America Corporation", "Chuka Taisen (US)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ -GAME( 1988, chukataij, chukatai, tnzs, chukatau, tnzs_state, chukatai, ROT0, "Taito Corporation", "Chuka Taisen (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, chukatai, 0, tnzs, chukatai, driver_device, 0, ROT0, "Taito Corporation Japan", "Chuka Taisen (World)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ +GAME( 1988, chukataiu, chukatai, tnzs, chukatau, driver_device, 0, ROT0, "Taito America Corporation", "Chuka Taisen (US)", MACHINE_SUPPORTS_SAVE ) /* Possible region hack */ +GAME( 1988, chukataij, chukatai, tnzs, chukatau, driver_device, 0, ROT0, "Taito Corporation", "Chuka Taisen (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, tnzs, 0, tnzsb, tnzs, tnzs_state, tnzsb, ROT0, "Taito Corporation Japan", "The NewZealand Story (World, new version) (newer PCB)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, tnzsj, tnzs, tnzsb, tnzsj, tnzs_state, tnzsb, ROT0, "Taito Corporation", "The NewZealand Story (Japan, new version) (newer PCB)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, tnzsjo, tnzs, tnzs, tnzsjo, tnzs_state, tnzs, ROT0, "Taito Corporation", "The NewZealand Story (Japan, old version) (older PCB)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, tnzsuo, tnzs, tnzs, tnzsjo, tnzs_state, tnzs, ROT0, "Taito America Corporation", "The NewZealand Story (US, old version) (older PCB)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, tnzso, tnzs, tnzs, tnzsop, tnzs_state, tnzs, ROT0, "Taito Corporation Japan", "The NewZealand Story (World, old version) (older PCB)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, tnzsop, tnzs, tnzs, tnzsop, tnzs_state, tnzs, ROT0, "Taito Corporation Japan", "The NewZealand Story (World, prototype?) (older PCB)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, tnzs, 0, tnzsb, tnzs, driver_device, 0, ROT0, "Taito Corporation Japan", "The NewZealand Story (World, new version) (newer PCB)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, tnzsj, tnzs, tnzsb, tnzsj, driver_device, 0, ROT0, "Taito Corporation", "The NewZealand Story (Japan, new version) (newer PCB)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, tnzsjo, tnzs, tnzs, tnzsjo, driver_device, 0, ROT0, "Taito Corporation", "The NewZealand Story (Japan, old version) (older PCB)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, tnzsuo, tnzs, tnzs, tnzsjo, driver_device, 0, ROT0, "Taito America Corporation", "The NewZealand Story (US, old version) (older PCB)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, tnzso, tnzs, tnzs, tnzsop, driver_device, 0, ROT0, "Taito Corporation Japan", "The NewZealand Story (World, old version) (older PCB)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, tnzsop, tnzs, tnzs, tnzsop, driver_device, 0, ROT0, "Taito Corporation Japan", "The NewZealand Story (World, prototype?) (older PCB)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, kabukiz, 0, kabukiz, kabukiz, tnzs_state, kabukiz, ROT0, "Kaneko / Taito Corporation Japan", "Kabuki-Z (World)", MACHINE_SUPPORTS_SAVE ) -GAME( 1988, kabukizj, kabukiz, kabukiz, kabukizj, tnzs_state, kabukiz, ROT0, "Kaneko / Taito Corporation", "Kabuki-Z (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, kabukiz, 0, kabukiz, kabukiz, driver_device, 0, ROT0, "Kaneko / Taito Corporation Japan", "Kabuki-Z (World)", MACHINE_SUPPORTS_SAVE ) +GAME( 1988, kabukizj, kabukiz, kabukiz, kabukizj, driver_device, 0, ROT0, "Kaneko / Taito Corporation", "Kabuki-Z (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1989, insectx, 0, insectx, insectx, tnzs_state, insectx, ROT0, "Taito Corporation Japan", "Insector X (World)", MACHINE_SUPPORTS_SAVE ) -GAME( 1989, insectxj, insectx, insectx, insectxj, tnzs_state, insectx, ROT0, "Taito Corporation", "Insector X (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1989, insectx, 0, insectx, insectx, driver_device, 0, ROT0, "Taito Corporation Japan", "Insector X (World)", MACHINE_SUPPORTS_SAVE ) +GAME( 1989, insectxj, insectx, insectx, insectxj, driver_device, 0, ROT0, "Taito Corporation", "Insector X (Japan)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/tnzs.h b/src/mame/includes/tnzs.h index 1a7ff1d9052..7a418ce226f 100644 --- a/src/mame/includes/tnzs.h +++ b/src/mame/includes/tnzs.h @@ -1,6 +1,11 @@ // license:BSD-3-Clause // copyright-holders:Luca Elia, Mirko Buffoni, Takahiro Nogi +#pragma once + +#ifndef MAME_INCLUDES_TNZS_H +#define MAME_INCLUDES_TNZS_H + #include "sound/dac.h" #include "sound/samples.h" #include "video/seta001.h" @@ -10,74 +15,128 @@ #define MAX_SAMPLES 0x2f /* max samples */ -enum -{ - MCU_ARKANOID_SIM = 0, - MCU_MCHIP_LLE, - MCU_NONE_INSECTX, - MCU_NONE_KAGEKI, - MCU_NONE_TNZSB, - MCU_NONE_KABUKIZ -}; - -class tnzs_state : public driver_device +class tnzs_base_state : public driver_device { public: - tnzs_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_subcpu(*this, "sub"), - m_mcu(*this, "mcu"), - m_seta001(*this, "spritegen"), - m_samples(*this, "samples"), - m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch"), - m_mainbank(*this, "mainbank"), - m_subbank(*this, "subbank"), - m_audiobank(*this, "audiobank"), - m_dswa(*this, "DSWA"), - m_dswb(*this, "DSWB"), - m_in0(*this, "IN0"), - m_in1(*this, "IN1"), - m_in2(*this, "IN2"), - m_coin1(*this, "COIN1"), - m_coin2(*this, "COIN2"), - m_an1(*this, "AN1"), - m_an2(*this, "AN2"), - m_lockout_level(false) + tnzs_base_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_subcpu(*this, "sub") + , m_seta001(*this, "spritegen") + , m_palette(*this, "palette") + , m_mainbank(*this, "mainbank") + , m_subbank(*this, "subbank") + , m_an1(*this, "AN1") + , m_an2(*this, "AN2") { } + virtual void machine_start() override; + + virtual DECLARE_WRITE8_MEMBER(bankswitch1_w); + + DECLARE_WRITE8_MEMBER(ramrom_bankswitch_w); + + uint32_t screen_update_tnzs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void screen_eof_tnzs(screen_device &screen, bool state); + + DECLARE_READ8_MEMBER(analog_r); // TODO: Move into a subclass + + DECLARE_PALETTE_INIT(prompalette); + +protected: /* devices */ required_device<cpu_device> m_maincpu; - optional_device<cpu_device> m_audiocpu; optional_device<cpu_device> m_subcpu; - optional_device<upi41_cpu_device> m_mcu; optional_device<seta001_device> m_seta001; - optional_device<samples_device> m_samples; required_device<palette_device> m_palette; - optional_device<generic_latch_8_device> m_soundlatch; - optional_device<address_map_bank_device> m_mainbank; - optional_memory_bank m_subbank; /* optional because of reuse from cchance.c */ - optional_memory_bank m_audiobank; - required_ioport m_dswa; - required_ioport m_dswb; + optional_device<address_map_bank_device> m_mainbank; /* FIXME: optional because of reuse from cchance.cpp */ + optional_memory_bank m_subbank; /* FIXME: optional because of reuse from cchance.cpp */ + + optional_ioport m_an1; // TODO: Move these into a subclass + optional_ioport m_an2; + + /* misc / mcu */ + int m_bank2; +}; + +class tnzs_mcu_state : public tnzs_base_state +{ +public: + tnzs_mcu_state(const machine_config &mconfig, device_type type, const char *tag, bool lockout_level) + : tnzs_base_state(mconfig, type, tag) + , m_mcu(*this, "mcu") + , m_in0(*this, "IN0") + , m_in1(*this, "IN1") + , m_in2(*this, "IN2") + , m_input_select(0) + , m_lockout_level(lockout_level) + { } + + virtual DECLARE_WRITE8_MEMBER(bankswitch1_w) override; + + DECLARE_READ8_MEMBER(mcu_port1_r); + DECLARE_READ8_MEMBER(mcu_port2_r); + DECLARE_WRITE8_MEMBER(mcu_port2_w ); + DECLARE_READ8_MEMBER(mcu_r); + DECLARE_WRITE8_MEMBER(mcu_w); + +protected: + required_device<upi41_cpu_device> m_mcu; + required_ioport m_in0; required_ioport m_in1; required_ioport m_in2; - optional_ioport m_coin1; - optional_ioport m_coin2; - optional_ioport m_an1; - optional_ioport m_an2; - - /* sound-related */ - std::unique_ptr<int16_t[]> m_sampledata[MAX_SAMPLES]; - int m_samplesize[MAX_SAMPLES]; - /* misc / mcu */ - int m_kageki_csport_sel; int m_input_select; - int m_mcu_type; + bool m_lockout_level; +}; + +class tnzs_state : public tnzs_mcu_state +{ +public: + tnzs_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzs_mcu_state(mconfig, type, tag, true) + { } +}; + +class extrmatn_state : public tnzs_mcu_state +{ +public: + extrmatn_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzs_mcu_state(mconfig, type, tag, false) + { } +}; + +class arknoid2_state : public extrmatn_state +{ +public: + arknoid2_state(const machine_config &mconfig, device_type type, const char *tag) + : extrmatn_state(mconfig, type, tag) + , m_coin1(*this, "COIN1") + , m_coin2(*this, "COIN2") + , m_in0(*this, "IN0") + , m_in1(*this, "IN1") + , m_in2(*this, "IN2") + { } + + virtual void machine_start() override; + virtual void machine_reset() override; + + virtual DECLARE_WRITE8_MEMBER(bankswitch1_w) override; + + DECLARE_READ8_MEMBER(mcu_r); + DECLARE_WRITE8_MEMBER(mcu_w); + INTERRUPT_GEN_MEMBER(mcu_interrupt); + +private: + required_ioport m_coin1; + required_ioport m_coin2; + required_ioport m_in0; + required_ioport m_in1; + required_ioport m_in2; + + void mcu_reset(); + int m_mcu_initializing; int m_mcu_coinage_init; int m_mcu_command; @@ -88,55 +147,103 @@ public: uint8_t m_mcu_coins_a; uint8_t m_mcu_coins_b; uint8_t m_mcu_credits; - int m_bank2; - bool m_lockout_level; - DECLARE_READ8_MEMBER(mcu_port1_r); - DECLARE_READ8_MEMBER(mcu_port2_r); - DECLARE_WRITE8_MEMBER(mcu_port2_w ); - DECLARE_READ8_MEMBER(mcu_r); - DECLARE_WRITE8_MEMBER(mcu_w); + void mcu_handle_coins(int coin); +}; + +class kageki_state : public tnzs_base_state +{ +public: + kageki_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzs_base_state(mconfig, type, tag) + , m_samples(*this, "samples") + , m_dswa(*this, "DSWA") + , m_dswb(*this, "DSWB") + , m_csport_sel(0) + { } + + virtual void machine_start() override; + virtual void machine_reset() override; - DECLARE_WRITE8_MEMBER(tnzsb_sound_command_w); - DECLARE_WRITE8_MEMBER(jpopnics_subbankswitch_w); - DECLARE_READ8_MEMBER(tnzs_port1_r); - DECLARE_READ8_MEMBER(tnzs_port2_r); - DECLARE_WRITE8_MEMBER(tnzs_port2_w); - DECLARE_WRITE8_MEMBER(extrmatn_port2_w); - DECLARE_READ8_MEMBER(arknoid2_sh_f000_r); - DECLARE_WRITE8_MEMBER(tnzs_ramrom_bankswitch_w); - DECLARE_WRITE8_MEMBER(tnzs_bankswitch1_w); - DECLARE_READ8_MEMBER(arknoid2_mcu_r); - DECLARE_WRITE8_MEMBER(arknoid2_mcu_w); - DECLARE_WRITE8_MEMBER(arknoid2_mcu_reset_w); - DECLARE_READ8_MEMBER(kageki_csport_r); - DECLARE_WRITE8_MEMBER(kageki_csport_w); - DECLARE_WRITE8_MEMBER(kabukiz_sound_bank_w); - DECLARE_WRITE_LINE_MEMBER(irqhandler); - - SAMPLES_START_CB_MEMBER(kageki_init_samples); - - DECLARE_DRIVER_INIT(arknoid2); - DECLARE_DRIVER_INIT(extrmatn); - DECLARE_DRIVER_INIT(drtoppel); - DECLARE_DRIVER_INIT(kabukiz); - DECLARE_DRIVER_INIT(plumpop); - DECLARE_DRIVER_INIT(insectx); - DECLARE_DRIVER_INIT(tnzs); + virtual DECLARE_WRITE8_MEMBER(bankswitch1_w) override; + + DECLARE_READ8_MEMBER(csport_r); + DECLARE_WRITE8_MEMBER(csport_w); + + DECLARE_MACHINE_RESET(kageki); DECLARE_DRIVER_INIT(kageki); - DECLARE_DRIVER_INIT(chukatai); - DECLARE_DRIVER_INIT(tnzsb); - DECLARE_MACHINE_START(tnzs); - DECLARE_MACHINE_RESET(tnzs); - DECLARE_PALETTE_INIT(arknoid2); - DECLARE_MACHINE_START(tnzs_common); - DECLARE_MACHINE_RESET(jpopnics); - uint32_t screen_update_tnzs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void screen_eof_tnzs(screen_device &screen, bool state); + SAMPLES_START_CB_MEMBER(init_samples); - INTERRUPT_GEN_MEMBER(arknoid2_interrupt); +private: + required_device<samples_device> m_samples; - void arknoid2_mcu_reset(); - void mcu_handle_coins(int coin); + required_ioport m_dswa; + required_ioport m_dswb; + + /* sound-related */ + std::unique_ptr<int16_t[]> m_sampledata[MAX_SAMPLES]; + int m_samplesize[MAX_SAMPLES]; + + int m_csport_sel; }; + +class jpopnics_state : public tnzs_base_state +{ +public: + jpopnics_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzs_base_state(mconfig, type, tag) + { } + + virtual void machine_reset() override; + + DECLARE_WRITE8_MEMBER(subbankswitch_w); +}; + +class insectx_state : public tnzs_base_state +{ +public: + insectx_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzs_base_state(mconfig, type, tag) + { } + + virtual DECLARE_WRITE8_MEMBER(bankswitch1_w) override; +}; + +class tnzsb_state : public tnzs_base_state +{ +public: + tnzsb_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzs_base_state(mconfig, type, tag) + , m_audiocpu(*this, "audiocpu") + , m_soundlatch(*this, "soundlatch") + { } + + DECLARE_WRITE_LINE_MEMBER(ym2203_irqhandler); + + DECLARE_WRITE8_MEMBER(sound_command_w); + + virtual DECLARE_WRITE8_MEMBER(bankswitch1_w) override; + +protected: + required_device<cpu_device> m_audiocpu; + required_device<generic_latch_8_device> m_soundlatch; +}; + +class kabukiz_state : public tnzsb_state +{ +public: + kabukiz_state(const machine_config &mconfig, device_type type, const char *tag) + : tnzsb_state(mconfig, type, tag) + , m_audiobank(*this, "audiobank") + { } + + virtual void machine_start() override; + + DECLARE_WRITE8_MEMBER(sound_bank_w); + +protected: + required_memory_bank m_audiobank; +}; + +#endif // MAME_INCLUDES_TNZS_H
\ No newline at end of file diff --git a/src/mame/machine/tnzs.cpp b/src/mame/machine/tnzs.cpp index 2119cfe2771..58a8559830f 100644 --- a/src/mame/machine/tnzs.cpp +++ b/src/mame/machine/tnzs.cpp @@ -18,7 +18,7 @@ #include "cpu/mcs48/mcs48.h" #include "includes/tnzs.h" -READ8_MEMBER(tnzs_state::mcu_r) +READ8_MEMBER(tnzs_mcu_state::mcu_r) { uint8_t data = m_mcu->upi41_master_r(space, offset & 1); space.device().execute().yield(); @@ -28,14 +28,14 @@ READ8_MEMBER(tnzs_state::mcu_r) return data; } -WRITE8_MEMBER(tnzs_state::mcu_w) +WRITE8_MEMBER(tnzs_mcu_state::mcu_w) { // logerror("PC %04x: write %02x to mcu $c00%01x\n", space.device().safe_pcbase(), data, offset); m_mcu->upi41_master_w(space, offset & 1, data); } -READ8_MEMBER(tnzs_state::mcu_port1_r) +READ8_MEMBER(tnzs_mcu_state::mcu_port1_r) { int data = 0; @@ -52,12 +52,12 @@ READ8_MEMBER(tnzs_state::mcu_port1_r) return data; } -READ8_MEMBER(tnzs_state::mcu_port2_r) +READ8_MEMBER(tnzs_mcu_state::mcu_port2_r) { return m_in2->read(); } -WRITE8_MEMBER(tnzs_state::mcu_port2_w) +WRITE8_MEMBER(tnzs_mcu_state::mcu_port2_w) { machine().bookkeeping().coin_lockout_w(0, (data & 0x40) != 0 ? m_lockout_level : !m_lockout_level); machine().bookkeeping().coin_lockout_w(1, (data & 0x80) != 0 ? m_lockout_level : !m_lockout_level); @@ -67,20 +67,18 @@ WRITE8_MEMBER(tnzs_state::mcu_port2_w) m_input_select = data & 0xf; } -READ8_MEMBER(tnzs_state::arknoid2_sh_f000_r) +// TODO: Eliminate this once arknoid2 MCU is dumped +READ8_MEMBER(tnzs_base_state::analog_r) { -// logerror("PC %04x: read input %04x\n", space.device().safe_pc(), 0xf000 + offset); - - int val = ((offset / 2) ? m_an2 : m_an1).read_safe(0); + uint16_t val = ((offset & 2) ? m_an2 : m_an1).read_safe(0); if (offset & 1) - return ((val >> 8) & 0xff); - else - return val & 0xff; -} + return val >> 8; + return val; +} -void tnzs_state::arknoid2_mcu_reset() +void arknoid2_state::mcu_reset() { m_mcu_initializing = 3; m_mcu_coinage_init = 0; @@ -95,7 +93,7 @@ void tnzs_state::arknoid2_mcu_reset() m_mcu_command = 0; } -void tnzs_state::mcu_handle_coins( int coin ) +void arknoid2_state::mcu_handle_coins( int coin ) { /* The coin inputs and coin counters are managed by the i8742 mcu. */ /* Here we simulate it. */ @@ -212,91 +210,18 @@ interleave. *********************************/ /* -TIMER_CALLBACK_MEMBER(tnzs_state::kludge_callback) +TIMER_CALLBACK_MEMBER(tnzs_base_state::kludge_callback) { tnzs_sharedram[0x0f10] = param; } -WRITE8_MEMBER(tnzs_state::tnzs_sync_kludge_w) +WRITE8_MEMBER(tnzs_base_state::tnzs_sync_kludge_w) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(tnzs_state::kludge_callback),this), data); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(tnzs_base_state::kludge_callback),this), data); } */ - - -DRIVER_INIT_MEMBER(tnzs_state,plumpop) -{ - m_mcu_type = MCU_MCHIP_LLE; - m_lockout_level = false; -} - -DRIVER_INIT_MEMBER(tnzs_state,extrmatn) -{ - m_mcu_type = MCU_MCHIP_LLE; - m_lockout_level = false; -} - -DRIVER_INIT_MEMBER(tnzs_state,arknoid2) -{ - m_mcu_type = MCU_ARKANOID_SIM; -} - -DRIVER_INIT_MEMBER(tnzs_state,drtoppel) -{ - /* drtoppel writes to the palette RAM area even if it has PROMs! We have to patch it out. */ - m_maincpu->space(AS_PROGRAM).nop_write(0xf800, 0xfbff); - m_lockout_level = false; - m_mcu_type = MCU_MCHIP_LLE; -} - -DRIVER_INIT_MEMBER(tnzs_state,chukatai) -{ - m_lockout_level = true; - m_mcu_type = MCU_MCHIP_LLE; -} - -DRIVER_INIT_MEMBER(tnzs_state,tnzs) -{ - /* we need to install a kludge to avoid problems with a bug in the original code */ -// m_maincpu->space(AS_PROGRAM).install_write_handler(0xef10, 0xef10, write8_delegate(FUNC(tnzs_state::tnzs_sync_kludge_w), this)); - m_lockout_level = true; - m_mcu_type = MCU_MCHIP_LLE; -} - -DRIVER_INIT_MEMBER(tnzs_state,tnzsb) -{ - m_mcu_type = MCU_NONE_TNZSB; - - /* we need to install a kludge to avoid problems with a bug in the original code */ -// m_maincpu->space(AS_PROGRAM).install_write_handler(0xef10, 0xef10, write8_delegate(FUNC(tnzs_state::tnzs_sync_kludge_w), this)); -} - -DRIVER_INIT_MEMBER(tnzs_state,kabukiz) -{ - uint8_t *SOUND = memregion("audiocpu")->base(); - m_mcu_type = MCU_NONE_KABUKIZ; - - m_audiobank->configure_entries(0, 8, &SOUND[0x00000], 0x4000); -} - -DRIVER_INIT_MEMBER(tnzs_state,insectx) -{ - m_mcu_type = MCU_NONE_INSECTX; - - /* this game has no mcu, replace the handler with plain input port handlers */ - m_subcpu->space(AS_PROGRAM).install_read_port(0xc000, 0xc000, "IN0" ); - m_subcpu->space(AS_PROGRAM).install_read_port(0xc001, 0xc001, "IN1" ); - m_subcpu->space(AS_PROGRAM).install_read_port(0xc002, 0xc002, "IN2" ); -} - -DRIVER_INIT_MEMBER(tnzs_state,kageki) -{ - m_mcu_type = MCU_NONE_KAGEKI; -} - - -READ8_MEMBER(tnzs_state::arknoid2_mcu_r) +READ8_MEMBER(arknoid2_state::mcu_r) { static const char mcu_startup[] = "\x55\xaa\x5a"; @@ -357,7 +282,7 @@ READ8_MEMBER(tnzs_state::arknoid2_mcu_r) } } -WRITE8_MEMBER(tnzs_state::arknoid2_mcu_w) +WRITE8_MEMBER(arknoid2_state::mcu_w) { if (offset == 0) { @@ -401,7 +326,7 @@ WRITE8_MEMBER(tnzs_state::arknoid2_mcu_w) } } -INTERRUPT_GEN_MEMBER(tnzs_state::arknoid2_interrupt) +INTERRUPT_GEN_MEMBER(arknoid2_state::mcu_interrupt) { int coin = ((m_coin1->read() & 1) << 0); coin |= ((m_coin2->read() & 1) << 1); @@ -412,41 +337,37 @@ INTERRUPT_GEN_MEMBER(tnzs_state::arknoid2_interrupt) device.execute().set_input_line(0, HOLD_LINE); } -MACHINE_RESET_MEMBER(tnzs_state,tnzs) +void arknoid2_state::machine_reset() { /* initialize the mcu simulation */ - if (m_mcu_type == MCU_ARKANOID_SIM) - arknoid2_mcu_reset(); + mcu_reset(); - m_kageki_csport_sel = 0; - m_mcu_readcredits = 0; // this might belong to arknoid2_mcu_reset - m_insertcoin = 0; // this might belong to arknoid2_mcu_reset + m_mcu_readcredits = 0; + m_insertcoin = 0; } -MACHINE_RESET_MEMBER(tnzs_state,jpopnics) +void kageki_state::machine_reset() { - m_mcu_type = -1; + tnzs_base_state::machine_reset(); + m_csport_sel = 0; } - -MACHINE_START_MEMBER(tnzs_state,tnzs_common) +void tnzs_base_state::machine_start() { - uint8_t *SUB = memregion("sub")->base(); - - m_subbank->configure_entries(0, 4, &SUB[0x08000], 0x2000); - m_subbank->set_entry(m_bank2); + uint8_t *sub = memregion("sub")->base(); m_bank2 = 0; m_mainbank->set_bank(2); + m_subbank->configure_entries(0, 4, &sub[0x08000], 0x2000); + m_subbank->set_entry(m_bank2); + save_item(NAME(m_bank2)); } -MACHINE_START_MEMBER(tnzs_state,tnzs) +void arknoid2_state::machine_start() { - MACHINE_START_CALL_MEMBER( tnzs_common ); - - save_item(NAME(m_kageki_csport_sel)); + tnzs_base_state::machine_start(); save_item(NAME(m_mcu_readcredits)); save_item(NAME(m_insertcoin)); save_item(NAME(m_mcu_initializing)); @@ -457,11 +378,22 @@ MACHINE_START_MEMBER(tnzs_state,tnzs) save_item(NAME(m_mcu_credits)); save_item(NAME(m_mcu_reportcoin)); save_item(NAME(m_mcu_command)); +} +void kageki_state::machine_start() +{ + tnzs_base_state::machine_start(); + save_item(NAME(m_csport_sel)); } +void kabukiz_state::machine_start() +{ + tnzs_base_state::machine_start(); + uint8_t *sound = memregion("audiocpu")->base(); + m_audiobank->configure_entries(0, 8, &sound[0x00000], 0x4000); +} -WRITE8_MEMBER(tnzs_state::tnzs_ramrom_bankswitch_w) +WRITE8_MEMBER(tnzs_base_state::ramrom_bankswitch_w) { // logerror("PC %04x: writing %02x to bankswitch\n", space.device().safe_pc(),data); @@ -475,49 +407,81 @@ WRITE8_MEMBER(tnzs_state::tnzs_ramrom_bankswitch_w) m_mainbank->set_bank(data & 0x07); } -WRITE8_MEMBER(tnzs_state::arknoid2_mcu_reset_w) +WRITE8_MEMBER(arknoid2_state::bankswitch1_w) { + tnzs_base_state::bankswitch1_w(space, offset, data, mem_mask); if (data & 0x04) - arknoid2_mcu_reset(); + mcu_reset(); +} - /* bits 0-1 select ROM bank */ - m_bank2 = data & 0x03; - m_subbank->set_entry(m_bank2); +WRITE8_MEMBER(insectx_state::bankswitch1_w) +{ + tnzs_base_state::bankswitch1_w(space, offset, data, mem_mask); + machine().bookkeeping().coin_lockout_w(0, (~data & 0x04)); + machine().bookkeeping().coin_lockout_w(1, (~data & 0x08)); + machine().bookkeeping().coin_counter_w(0, (data & 0x10)); + machine().bookkeeping().coin_counter_w(1, (data & 0x20)); } -WRITE8_MEMBER(tnzs_state::tnzs_bankswitch1_w) +WRITE8_MEMBER(tnzsb_state::bankswitch1_w) // kabukiz_state { -// logerror("PC %04x: writing %02x to bankswitch 1\n", space.device().safe_pc(),data); + tnzs_base_state::bankswitch1_w(space, offset, data, mem_mask); + machine().bookkeeping().coin_lockout_w(0, (~data & 0x10)); + machine().bookkeeping().coin_lockout_w(1, (~data & 0x20)); + machine().bookkeeping().coin_counter_w(0, (data & 0x04)); + machine().bookkeeping().coin_counter_w(1, (data & 0x08)); +} - switch (m_mcu_type) - { - case MCU_MCHIP_LLE: - if ((data & 0x04) != 0 && m_mcu != nullptr) - m_mcu->set_input_line(INPUT_LINE_RESET, PULSE_LINE); - break; - case MCU_NONE_INSECTX: - machine().bookkeeping().coin_lockout_w(0, (~data & 0x04)); - machine().bookkeeping().coin_lockout_w(1, (~data & 0x08)); - machine().bookkeeping().coin_counter_w(0, (data & 0x10)); - machine().bookkeeping().coin_counter_w(1, (data & 0x20)); - break; - case MCU_NONE_TNZSB: - case MCU_NONE_KABUKIZ: - machine().bookkeeping().coin_lockout_w(0, (~data & 0x10)); - machine().bookkeeping().coin_lockout_w(1, (~data & 0x20)); - machine().bookkeeping().coin_counter_w(0, (data & 0x04)); - machine().bookkeeping().coin_counter_w(1, (data & 0x08)); - break; - case MCU_NONE_KAGEKI: - machine().bookkeeping().coin_lockout_global_w((~data & 0x20)); - machine().bookkeeping().coin_counter_w(0, (data & 0x04)); - machine().bookkeeping().coin_counter_w(1, (data & 0x08)); - break; - default: - break; - } +WRITE8_MEMBER(kageki_state::bankswitch1_w) +{ + tnzs_base_state::bankswitch1_w(space, offset, data, mem_mask); + machine().bookkeeping().coin_lockout_global_w((~data & 0x20)); + machine().bookkeeping().coin_counter_w(0, (data & 0x04)); + machine().bookkeeping().coin_counter_w(1, (data & 0x08)); +} + +WRITE8_MEMBER(tnzs_mcu_state::bankswitch1_w) +{ + tnzs_base_state::bankswitch1_w(space, offset, data, mem_mask); + if ((data & 0x04) != 0 && m_mcu != nullptr) + m_mcu->set_input_line(INPUT_LINE_RESET, PULSE_LINE); +} + +WRITE8_MEMBER(tnzs_base_state::bankswitch1_w) +{ +// logerror("PC %04x: writing %02x to bankswitch 1\n", space.device().safe_pc(),data); /* bits 0-1 select ROM bank */ m_bank2 = data & 0x03; m_subbank->set_entry(m_bank2); } + +void jpopnics_state::machine_reset() +{ + tnzs_base_state::machine_reset(); +} + +WRITE8_MEMBER(jpopnics_state::subbankswitch_w) +{ + /* bits 0-1 select ROM bank */ + m_subbank->set_entry(data & 0x03); +} + +WRITE8_MEMBER(tnzsb_state::sound_command_w) +{ + m_soundlatch->write(space, offset, data); + m_audiocpu->set_input_line_and_vector(0, HOLD_LINE, 0xff); +} + +/* handler called by the 2203 emulator when the internal timers cause an IRQ */ +WRITE_LINE_MEMBER(tnzsb_state::ym2203_irqhandler) +{ + m_audiocpu->set_input_line(INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); +} + +WRITE8_MEMBER(kabukiz_state::sound_bank_w) +{ + // to avoid the write when the sound chip is initialized + if (data != 0xff) + m_audiobank->set_entry(data & 0x07); +} diff --git a/src/mame/video/tnzs.cpp b/src/mame/video/tnzs.cpp index 78bc5416649..803c39d67ac 100644 --- a/src/mame/video/tnzs.cpp +++ b/src/mame/video/tnzs.cpp @@ -31,20 +31,19 @@ ***************************************************************************/ -PALETTE_INIT_MEMBER(tnzs_state,arknoid2) +PALETTE_INIT_MEMBER(tnzs_base_state, prompalette) { const uint8_t *color_prom = memregion("proms")->base(); - int i, col; - for (i = 0; i < palette.entries(); i++) + for (int i = 0; i < palette.entries(); i++) { - col = (color_prom[i] << 8) + color_prom[i + 512]; + int col = (color_prom[i] << 8) + color_prom[i + 512]; palette.set_pen_color(i, pal5bit(col >> 10), pal5bit(col >> 5), pal5bit(col >> 0)); } } -uint32_t tnzs_state::screen_update_tnzs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +uint32_t tnzs_base_state::screen_update_tnzs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { bitmap.fill(0x1f0, cliprect); @@ -55,7 +54,7 @@ uint32_t tnzs_state::screen_update_tnzs(screen_device &screen, bitmap_ind16 &bit return 0; } -void tnzs_state::screen_eof_tnzs(screen_device &screen, bool state) +void tnzs_base_state::screen_eof_tnzs(screen_device &screen, bool state) { // rising edge if (state) |