diff --git a/src/mess/drivers/hh_hmcs40.c b/src/mess/drivers/hh_hmcs40.c index c06521aed8a..a523bb6e16c 100644 --- a/src/mess/drivers/hh_hmcs40.c +++ b/src/mess/drivers/hh_hmcs40.c @@ -68,8 +68,8 @@ public: optional_device m_speaker; // misc common - UINT8 m_r[8]; // MCU R ports write data - UINT16 m_d; // MCU D port write data + UINT8 m_r[8]; // MCU R ports write data (optional) + UINT16 m_d; // MCU D port write data (optional) UINT8 m_int[2]; // MCU INT0/1 pins state UINT16 m_inp_mux; // multiplexed inputs mask @@ -96,64 +96,6 @@ public: void set_display_size(int maxx, int maxy); void display_matrix(int maxx, int maxy, UINT64 setx, UINT32 sety); - // game-specific handlers - DECLARE_WRITE8_MEMBER(bambball_plate_w); - DECLARE_WRITE16_MEMBER(bambball_grid_w); - DECLARE_READ8_MEMBER(bambball_input_r); - - DECLARE_WRITE8_MEMBER(alnattck_plate_w); - DECLARE_WRITE16_MEMBER(alnattck_grid_w); - DECLARE_READ16_MEMBER(alnattck_input_r); - - DECLARE_WRITE8_MEMBER(packmon_plate_w); - DECLARE_WRITE16_MEMBER(packmon_grid_w); - DECLARE_READ16_MEMBER(packmon_input_r); - - DECLARE_WRITE8_MEMBER(zackman_plate_w); - DECLARE_WRITE16_MEMBER(zackman_grid_w); - void zackman_update_int0(); - DECLARE_INPUT_CHANGED_MEMBER(zackman_input_changed); - - int m_cdkong_speaker_volume; - TIMER_DEVICE_CALLBACK_MEMBER(cdkong_speaker_decay_sim); - void cdkong_display(); - DECLARE_WRITE8_MEMBER(cdkong_plate_w); - DECLARE_WRITE16_MEMBER(cdkong_grid_w); - DECLARE_MACHINE_START(cdkong); - - void cgalaxn_display(); - DECLARE_WRITE16_MEMBER(cgalaxn_plate_w); - DECLARE_WRITE8_MEMBER(cgalaxn_grid_w); - DECLARE_READ8_MEMBER(cgalaxn_input_r); - - DECLARE_WRITE8_MEMBER(cpacman_plate_w); - DECLARE_WRITE16_MEMBER(cpacman_grid_w); - DECLARE_READ8_MEMBER(cpacman_input_r); - - DECLARE_WRITE8_MEMBER(cmspacmn_plate_w); - DECLARE_WRITE16_MEMBER(cmspacmn_grid_w); - DECLARE_READ8_MEMBER(cmspacmn_input_r); - - void egalaxn2_display(); - DECLARE_WRITE8_MEMBER(egalaxn2_plate_w); - DECLARE_WRITE16_MEMBER(egalaxn2_grid_w); - DECLARE_READ8_MEMBER(egalaxn2_input_r); - - DECLARE_WRITE8_MEMBER(pbqbert_plate_w); - DECLARE_WRITE16_MEMBER(pbqbert_grid_w); - - void kingman_display(); - DECLARE_WRITE8_MEMBER(kingman_plate_w); - DECLARE_WRITE16_MEMBER(kingman_grid_w); - void kingman_update_int0(); - DECLARE_INPUT_CHANGED_MEMBER(kingman_input_changed); - - void tmtron_display(); - DECLARE_WRITE8_MEMBER(tmtron_plate_w); - DECLARE_WRITE16_MEMBER(tmtron_grid_w); - void tmtron_update_int1(); - DECLARE_INPUT_CHANGED_MEMBER(tmtron_input_changed); - protected: virtual void machine_start(); virtual void machine_reset(); @@ -337,7 +279,7 @@ INPUT_CHANGED_MEMBER(hh_hmcs40_state::single_interrupt_line) /*************************************************************************** - Minidrivers (I/O, Inputs, Machine Config) + Minidrivers (subclass, I/O, Inputs, Machine Config) ***************************************************************************/ @@ -352,7 +294,21 @@ INPUT_CHANGED_MEMBER(hh_hmcs40_state::single_interrupt_line) ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::bambball_plate_w) +class bambball_state : public hh_hmcs40_state +{ +public: + bambball_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + DECLARE_READ8_MEMBER(input_r); +}; + +// handlers + +WRITE8_MEMBER(bambball_state::plate_w) { // R1x-R3x, D0-D3: vfd matrix plate int shift = (offset - HMCS40_PORT_R1X) * 4; @@ -360,11 +316,10 @@ WRITE8_MEMBER(hh_hmcs40_state::bambball_plate_w) // update display UINT16 plate = BITSWAP16(m_plate,13,8,4,12,9,10,14,1,7,0,15,11,6,3,5,2); - display_matrix(16, 9, plate, m_grid); } -WRITE16_MEMBER(hh_hmcs40_state::bambball_grid_w) +WRITE16_MEMBER(bambball_state::grid_w) { // D4: speaker out m_speaker->level_w(data >> 4 & 1); @@ -376,16 +331,18 @@ WRITE16_MEMBER(hh_hmcs40_state::bambball_grid_w) m_grid = data >> 7 & 0x1ff; // D0-D3: plates (update display there) - bambball_plate_w(space, 3 + HMCS40_PORT_R1X, data & 0xf); + plate_w(space, 3 + HMCS40_PORT_R1X, data & 0xf); } -READ8_MEMBER(hh_hmcs40_state::bambball_input_r) +READ8_MEMBER(bambball_state::input_r) { // R0x: inputs return read_inputs(4); } +// config + static INPUT_PORTS_START( bambball ) PORT_START("IN.0") // D7 port R0x PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Dribble Low") @@ -413,16 +370,15 @@ static INPUT_PORTS_START( bambball ) PORT_CONFSETTING( 0x00, "2" ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( bambball, hh_hmcs40_state ) +static MACHINE_CONFIG_START( bambball, bambball_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38750, 400000) // approximation - RC osc. - MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, bambball_input_r)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, bambball_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, bambball_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, bambball_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, bambball_grid_w)) + MCFG_HMCS40_READ_R_CB(0, READ8(bambball_state, input_r)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(bambball_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(bambball_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(bambball_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(bambball_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -450,7 +406,21 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::packmon_plate_w) +class packmon_state : public hh_hmcs40_state +{ +public: + packmon_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + DECLARE_READ16_MEMBER(input_r); +}; + +// handlers + +WRITE8_MEMBER(packmon_state::plate_w) { // R0x-R3x, D0-D3: vfd matrix plate int shift = offset * 4; @@ -459,11 +429,10 @@ WRITE8_MEMBER(hh_hmcs40_state::packmon_plate_w) // update display UINT16 grid = BITSWAP16(m_grid,15,14,13,12,11,10,0,1,2,3,4,5,6,7,8,9); UINT32 plate = BITSWAP24(m_plate,23,22,21,20,0,1,2,3,4,5,6,19,18,17,16,15,14,13,12,11,10,9,8,7); - display_matrix(20, 10, plate, grid); } -WRITE16_MEMBER(hh_hmcs40_state::packmon_grid_w) +WRITE16_MEMBER(packmon_state::grid_w) { // D4: speaker out m_speaker->level_w(data >> 4 & 1); @@ -475,16 +444,18 @@ WRITE16_MEMBER(hh_hmcs40_state::packmon_grid_w) m_grid = data >> 6 & 0x3ff; // D0-D3: plate 9-12 (update display there) - packmon_plate_w(space, 4, data & 0xf); + plate_w(space, 4, data & 0xf); } -READ16_MEMBER(hh_hmcs40_state::packmon_input_r) +READ16_MEMBER(packmon_state::input_r) { // D5: multiplexed inputs return read_inputs(5); } +// config + static INPUT_PORTS_START( packmon ) PORT_START("IN.0") // D11 line D5 PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START ) @@ -502,17 +473,16 @@ static INPUT_PORTS_START( packmon ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( packmon, hh_hmcs40_state ) +static MACHINE_CONFIG_START( packmon, packmon_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38800, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, packmon_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, packmon_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, packmon_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, packmon_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, packmon_grid_w)) - MCFG_HMCS40_READ_D_CB(READ16(hh_hmcs40_state, packmon_input_r)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(packmon_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(packmon_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(packmon_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(packmon_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(packmon_state, grid_w)) + MCFG_HMCS40_READ_D_CB(READ16(packmon_state, input_r)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -539,7 +509,23 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::zackman_plate_w) +class zackman_state : public hh_hmcs40_state +{ +public: + zackman_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + + void update_int0(); + DECLARE_INPUT_CHANGED_MEMBER(input_changed); +}; + +// handlers + +WRITE8_MEMBER(zackman_state::plate_w) { // R0x-R6x,D0,D1: vfd matrix plate int shift = offset * 4; @@ -548,11 +534,10 @@ WRITE8_MEMBER(hh_hmcs40_state::zackman_plate_w) // update display UINT8 grid = BITSWAP8(m_grid,0,1,2,3,4,5,6,7); UINT32 plate = BITSWAP32(m_plate,31,30,27,0,1,2,3,4,5,6,7,8,9,10,11,24,25,26,29,28,23,22,21,20,19,18,17,16,15,14,13,12); - display_matrix(29, 8, plate, grid); } -WRITE16_MEMBER(hh_hmcs40_state::zackman_grid_w) +WRITE16_MEMBER(zackman_state::grid_w) { // D2: speaker out m_speaker->level_w(data >> 2 & 1); @@ -562,58 +547,60 @@ WRITE16_MEMBER(hh_hmcs40_state::zackman_grid_w) if (inp_mux != m_inp_mux) { m_inp_mux = inp_mux; - zackman_update_int0(); + update_int0(); } // D8-D15: vfd matrix grid m_grid = data >> 8 & 0xff; // D0,D1: plate 12,13 (update display there) - zackman_plate_w(space, 7, data & 3); + plate_w(space, 7, data & 3); } -void hh_hmcs40_state::zackman_update_int0() +void zackman_state::update_int0() { // INT0 on multiplexed inputs set_interrupt(0, read_inputs(4)); } -INPUT_CHANGED_MEMBER(hh_hmcs40_state::zackman_input_changed) -{ - zackman_update_int0(); -} +// config static INPUT_PORTS_START( zackman ) PORT_START("IN.0") // D11 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, zackman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, zackman_state, input_changed, NULL) PORT_START("IN.1") // D12 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, zackman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, zackman_state, input_changed, NULL) PORT_START("IN.2") // D13 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, zackman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, zackman_state, input_changed, NULL) PORT_START("IN.3") // D14 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, zackman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, zackman_state, input_changed, NULL) PORT_START("IN.4") // INT1 PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)1) INPUT_PORTS_END +INPUT_CHANGED_MEMBER(zackman_state::input_changed) +{ + update_int0(); +} -static MACHINE_CONFIG_START( zackman, hh_hmcs40_state ) + +static MACHINE_CONFIG_START( zackman, zackman_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, zackman_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, zackman_grid_w)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(zackman_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(zackman_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -640,7 +627,21 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::alnattck_plate_w) +class alnattck_state : public hh_hmcs40_state +{ +public: + alnattck_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + DECLARE_READ16_MEMBER(input_r); +}; + +// handlers + +WRITE8_MEMBER(alnattck_state::plate_w) { // R0x-R3x, D0-D3: vfd matrix plate int shift = offset * 4; @@ -648,11 +649,10 @@ WRITE8_MEMBER(hh_hmcs40_state::alnattck_plate_w) // update display UINT32 plate = BITSWAP16(m_plate,11,9,8,10,7,2,0,1,3,4,5,6,12,13,14,15) | (m_plate & 0xf0000); - display_matrix(20, 10, plate, m_grid); } -WRITE16_MEMBER(hh_hmcs40_state::alnattck_grid_w) +WRITE16_MEMBER(alnattck_state::grid_w) { // D4: speaker out m_speaker->level_w(data >> 4 & 1); @@ -664,16 +664,18 @@ WRITE16_MEMBER(hh_hmcs40_state::alnattck_grid_w) m_grid = data >> 6 & 0x3ff; // D0-D3: plate 16-19 (update display there) - alnattck_plate_w(space, 4, data & 0xf); + plate_w(space, 4, data & 0xf); } -READ16_MEMBER(hh_hmcs40_state::alnattck_input_r) +READ16_MEMBER(alnattck_state::input_r) { // D5: multiplexed inputs return read_inputs(7); } +// config + static INPUT_PORTS_START( alnattck ) PORT_START("IN.0") // D5 D7 PORT_CONFNAME( 0x20, 0x00, "Skill Level" ) @@ -699,17 +701,16 @@ static INPUT_PORTS_START( alnattck ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Fire") INPUT_PORTS_END - -static MACHINE_CONFIG_START( alnattck, hh_hmcs40_state ) +static MACHINE_CONFIG_START( alnattck, alnattck_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38800, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, alnattck_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, alnattck_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, alnattck_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, alnattck_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, alnattck_grid_w)) - MCFG_HMCS40_READ_D_CB(READ16(hh_hmcs40_state, alnattck_input_r)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(alnattck_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(alnattck_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(alnattck_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(alnattck_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(alnattck_state, grid_w)) + MCFG_HMCS40_READ_D_CB(READ16(alnattck_state, input_r)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -737,6 +738,26 @@ MACHINE_CONFIG_END ***************************************************************************/ +class cdkong_state : public hh_hmcs40_state +{ +public: + cdkong_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + void cdkong_display(); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + + int m_speaker_volume; + TIMER_DEVICE_CALLBACK_MEMBER(speaker_decay_sim); + +protected: + virtual void machine_start(); +}; + +// handlers + // Sound is controlled by two pins: D3 for pitch, and R13 for on/off. When turned // off, it does not mute instantly, but volume slowly decays. Until we emulate it // with discrete audio, this crude simulation will do. @@ -744,24 +765,24 @@ MACHINE_CONFIG_END #define CDKONG_SPEAKER_MAX 0x10000 #define CDKONG_SPEAKER_DECAY 50 -TIMER_DEVICE_CALLBACK_MEMBER(hh_hmcs40_state::cdkong_speaker_decay_sim) +TIMER_DEVICE_CALLBACK_MEMBER(cdkong_state::speaker_decay_sim) { - m_speaker->set_output_gain(0, m_cdkong_speaker_volume / (double)CDKONG_SPEAKER_MAX); - m_cdkong_speaker_volume /= 2; + m_speaker->set_output_gain(0, m_speaker_volume / (double)CDKONG_SPEAKER_MAX); + m_speaker_volume /= 2; } -void hh_hmcs40_state::cdkong_display() + +void cdkong_state::cdkong_display() { UINT32 plate = BITSWAP32(m_plate,31,30,29,24,0,16,8,1,23,17,9,2,18,10,25,27,26,3,15,27,11,11,14,22,6,13,21,5,19,12,20,4); - display_matrix(29, 11, plate, m_grid); } -WRITE8_MEMBER(hh_hmcs40_state::cdkong_plate_w) +WRITE8_MEMBER(cdkong_state::plate_w) { // R13: speaker on if (offset == HMCS40_PORT_R1X && data & 8) - m_cdkong_speaker_volume = CDKONG_SPEAKER_MAX; + m_speaker_volume = CDKONG_SPEAKER_MAX; // R0x-R6x: vfd matrix plate int shift = offset * 4; @@ -769,7 +790,7 @@ WRITE8_MEMBER(hh_hmcs40_state::cdkong_plate_w) cdkong_display(); } -WRITE16_MEMBER(hh_hmcs40_state::cdkong_grid_w) +WRITE16_MEMBER(cdkong_state::grid_w) { // D3: speaker out m_speaker->level_w(data >> 3 & 1); @@ -780,6 +801,8 @@ WRITE16_MEMBER(hh_hmcs40_state::cdkong_grid_w) } +// config + static INPUT_PORTS_START( cdkong ) PORT_START("IN.0") // port D PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) @@ -793,35 +816,33 @@ static INPUT_PORTS_START( cdkong ) INPUT_PORTS_END -MACHINE_START_MEMBER(hh_hmcs40_state, cdkong) +void cdkong_state::machine_start() { hh_hmcs40_state::machine_start(); - + // zerofill/init - m_cdkong_speaker_volume = 0; - save_item(NAME(m_cdkong_speaker_volume)); + m_speaker_volume = 0; + save_item(NAME(m_speaker_volume)); } -static MACHINE_CONFIG_START( cdkong, hh_hmcs40_state ) +static MACHINE_CONFIG_START( cdkong, cdkong_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, cdkong_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, cdkong_grid_w)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(cdkong_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(cdkong_state, grid_w)) MCFG_HMCS40_READ_D_CB(IOPORT("IN.0")) - MCFG_TIMER_DRIVER_ADD_PERIODIC("speaker_decay", hh_hmcs40_state, cdkong_speaker_decay_sim, attotime::from_msec(CDKONG_SPEAKER_DECAY)) + MCFG_TIMER_DRIVER_ADD_PERIODIC("speaker_decay", cdkong_state, speaker_decay_sim, attotime::from_msec(CDKONG_SPEAKER_DECAY)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) - MCFG_MACHINE_START_OVERRIDE(hh_hmcs40_state, cdkong) - /* no video! */ /* sound hardware */ @@ -851,15 +872,29 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_hmcs40_state::cgalaxn_display() +class cgalaxn_state : public hh_hmcs40_state +{ +public: + cgalaxn_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + void cgalaxn_display(); + DECLARE_WRITE16_MEMBER(plate_w); + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_READ8_MEMBER(input_r); +}; + +// handlers + +void cgalaxn_state::cgalaxn_display() { UINT16 grid = BITSWAP16(m_grid,15,14,13,12,1,2,0,11,10,9,8,7,6,5,4,3); UINT16 plate = BITSWAP16(m_plate,15,14,5,4,3,2,1,0,7,11,12,9,8,10,6,13); - display_matrix(14, 12, plate, grid); } -WRITE8_MEMBER(hh_hmcs40_state::cgalaxn_grid_w) +WRITE8_MEMBER(cgalaxn_state::grid_w) { // D0: speaker out m_speaker->level_w(data & 1); @@ -869,15 +904,9 @@ WRITE8_MEMBER(hh_hmcs40_state::cgalaxn_grid_w) // D2-D15: vfd matrix plate m_plate = data >> 2 & 0x3fff; cgalaxn_display(); - - // a, f, g, c, e, d, h, b, p, o, n, m, k, i - - // 0, 5, 6, 2, 4, 3, 7, 1,13,12,11,10, 9, 8 - // 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 - // 15,14, 5, 4, 3, 2, 1, 0, 7,11,12, 9, 8,10, 6,13 } -WRITE16_MEMBER(hh_hmcs40_state::cgalaxn_plate_w) +WRITE16_MEMBER(cgalaxn_state::plate_w) { // R10,R11: input mux if (offset == HMCS40_PORT_R1X) @@ -886,23 +915,18 @@ WRITE16_MEMBER(hh_hmcs40_state::cgalaxn_plate_w) // R1x-R3x: vfd matrix grid int shift = (offset - HMCS40_PORT_R1X) * 4; m_grid = (m_grid & ~(0xf << shift)) | (data << shift); - cgalaxn_display(); - - // 9, 8, 7, 6, 5, 4, 3, 2, 1,11,12,10 - - // 8, 7, 6, 5, 4, 3, 2, 1, 0,10,11, 9 - // 15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 - // 15,14,13,12, 1, 2, 0,11,10, 9, 8, 7, 6, 5, 4, 3 } -READ8_MEMBER(hh_hmcs40_state::cgalaxn_input_r) +READ8_MEMBER(cgalaxn_state::input_r) { // R0x: multiplexed inputs return read_inputs(2); } +// config + static INPUT_PORTS_START( cgalaxn ) PORT_START("IN.0") // R10 port R0x PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) @@ -923,16 +947,15 @@ static INPUT_PORTS_START( cgalaxn ) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)1) INPUT_PORTS_END - -static MACHINE_CONFIG_START( cgalaxn, hh_hmcs40_state ) +static MACHINE_CONFIG_START( cgalaxn, cgalaxn_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38800, 400000) // approximation - RC osc. - MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, cgalaxn_input_r)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, cgalaxn_grid_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, cgalaxn_grid_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, cgalaxn_grid_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, cgalaxn_plate_w)) + MCFG_HMCS40_READ_R_CB(0, READ8(cgalaxn_state, input_r)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(cgalaxn_state, grid_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(cgalaxn_state, grid_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(cgalaxn_state, grid_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(cgalaxn_state, plate_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -970,7 +993,21 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::cpacman_plate_w) +class cpacman_state : public hh_hmcs40_state +{ +public: + cpacman_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + DECLARE_READ8_MEMBER(input_r); +}; + +// handlers + +WRITE8_MEMBER(cpacman_state::plate_w) { // R1x-R6x, D1,D2: vfd matrix plate int shift = (offset - HMCS40_PORT_R1X) * 4; @@ -979,11 +1016,10 @@ WRITE8_MEMBER(hh_hmcs40_state::cpacman_plate_w) // update display UINT16 grid = BITSWAP16(m_grid,15,14,13,12,11,0,1,2,3,4,5,6,7,8,9,10); UINT32 plate = BITSWAP32(m_plate,31,30,29,28,27,0,1,2,3,8,9,10,11,16,17,18,19,25,26,23,22,21,20,24,15,14,13,12,4,5,6,7); - display_matrix(27, 11, plate, grid); } -WRITE16_MEMBER(hh_hmcs40_state::cpacman_grid_w) +WRITE16_MEMBER(cpacman_state::grid_w) { // D0: speaker out m_speaker->level_w(data & 1); @@ -995,16 +1031,18 @@ WRITE16_MEMBER(hh_hmcs40_state::cpacman_grid_w) m_grid = data >> 5 & 0x7ff; // D1,D2: plate 8,14 (update display there) - cpacman_plate_w(space, 6 + HMCS40_PORT_R1X, data >> 1 & 3); + plate_w(space, 6 + HMCS40_PORT_R1X, data >> 1 & 3); } -READ8_MEMBER(hh_hmcs40_state::cpacman_input_r) +READ8_MEMBER(cpacman_state::input_r) { // R0x: multiplexed inputs return read_inputs(3); } +// config + static INPUT_PORTS_START( cpacman ) PORT_START("IN.0") // D13 port R0x PORT_CONFNAME( 0x01, 0x01, "Skill Level" ) @@ -1025,19 +1063,18 @@ static INPUT_PORTS_START( cpacman ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) INPUT_PORTS_END - -static MACHINE_CONFIG_START( cpacman, hh_hmcs40_state ) +static MACHINE_CONFIG_START( cpacman, cpacman_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, cpacman_input_r)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, cpacman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, cpacman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, cpacman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, cpacman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, cpacman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, cpacman_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, cpacman_grid_w)) + MCFG_HMCS40_READ_R_CB(0, READ8(cpacman_state, input_r)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(cpacman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(cpacman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(cpacman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(cpacman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(cpacman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(cpacman_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(cpacman_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -1073,7 +1110,21 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::cmspacmn_plate_w) +class cmspacmn_state : public hh_hmcs40_state +{ +public: + cmspacmn_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + DECLARE_READ8_MEMBER(input_r); +}; + +// handlers + +WRITE8_MEMBER(cmspacmn_state::plate_w) { // R1x-R6x, D0,D1: vfd matrix plate int shift = (offset - HMCS40_PORT_R1X) * 4; @@ -1082,11 +1133,10 @@ WRITE8_MEMBER(hh_hmcs40_state::cmspacmn_plate_w) // update display UINT16 grid = BITSWAP16(m_grid,15,14,13,11,10,9,8,7,6,5,4,3,2,1,0,1); UINT64 plate = BIT(m_plate,15)<<32 | BITSWAP32(m_plate,14,13,12,4,5,6,7,24,23,25,22,21,20,13,24,3,19,14,12,11,24,2,10,8,7,25,0,9,1,18,17,16); - display_matrix(33, 12, plate, grid); } -WRITE16_MEMBER(hh_hmcs40_state::cmspacmn_grid_w) +WRITE16_MEMBER(cmspacmn_state::grid_w) { // D2: speaker out m_speaker->level_w(data >> 2 & 1); @@ -1098,16 +1148,18 @@ WRITE16_MEMBER(hh_hmcs40_state::cmspacmn_grid_w) m_grid = data >> 5 & 0x7ff; // D0,D1: plate 11+17,6+22 (update display there) - cmspacmn_plate_w(space, 6 + HMCS40_PORT_R1X, data & 3); + plate_w(space, 6 + HMCS40_PORT_R1X, data & 3); } -READ8_MEMBER(hh_hmcs40_state::cmspacmn_input_r) +READ8_MEMBER(cmspacmn_state::input_r) { // R0x: multiplexed inputs return read_inputs(3); } +// config + static INPUT_PORTS_START( cmspacmn ) PORT_START("IN.0") // D13 port R0x PORT_CONFNAME( 0x01, 0x00, "Skill Level" ) @@ -1128,19 +1180,18 @@ static INPUT_PORTS_START( cmspacmn ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( cmspacmn, hh_hmcs40_state ) +static MACHINE_CONFIG_START( cmspacmn, cmspacmn_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, cmspacmn_input_r)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, cmspacmn_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, cmspacmn_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, cmspacmn_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, cmspacmn_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, cmspacmn_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, cmspacmn_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, cmspacmn_grid_w)) + MCFG_HMCS40_READ_R_CB(0, READ8(cmspacmn_state, input_r)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(cmspacmn_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(cmspacmn_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(cmspacmn_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(cmspacmn_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(cmspacmn_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(cmspacmn_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(cmspacmn_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -1167,15 +1218,29 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_hmcs40_state::egalaxn2_display() +class egalaxn2_state : public hh_hmcs40_state +{ +public: + egalaxn2_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + void egalaxn2_display(); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + DECLARE_READ8_MEMBER(input_r); +}; + +// handlers + +void egalaxn2_state::egalaxn2_display() { UINT16 grid = BITSWAP16(m_grid,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14); UINT32 plate = BITSWAP24(m_plate,23,22,21,20,15,14,13,12,7,6,5,4,3,2,1,0,19,18,17,16,11,10,9,8); - display_matrix(24, 15, plate, grid); } -WRITE16_MEMBER(hh_hmcs40_state::egalaxn2_grid_w) +WRITE16_MEMBER(egalaxn2_state::grid_w) { // D0: speaker out m_speaker->level_w(data & 1); @@ -1188,22 +1253,23 @@ WRITE16_MEMBER(hh_hmcs40_state::egalaxn2_grid_w) egalaxn2_display(); } -WRITE8_MEMBER(hh_hmcs40_state::egalaxn2_plate_w) +WRITE8_MEMBER(egalaxn2_state::plate_w) { // R1x-R6x: vfd matrix plate int shift = (offset - HMCS40_PORT_R1X) * 4; m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - egalaxn2_display(); } -READ8_MEMBER(hh_hmcs40_state::egalaxn2_input_r) +READ8_MEMBER(egalaxn2_state::input_r) { // R0x: multiplexed inputs return read_inputs(4); } +// config + static INPUT_PORTS_START( egalaxn2 ) PORT_START("IN.0") // D1 port R0x PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) @@ -1235,18 +1301,18 @@ static INPUT_PORTS_START( egalaxn2 ) INPUT_PORTS_END -static MACHINE_CONFIG_START( egalaxn2, hh_hmcs40_state ) +static MACHINE_CONFIG_START( egalaxn2, egalaxn2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, egalaxn2_input_r)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, egalaxn2_grid_w)) + MCFG_HMCS40_READ_R_CB(0, READ8(egalaxn2_state, input_r)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(egalaxn2_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -1273,7 +1339,18 @@ MACHINE_CONFIG_END ***************************************************************************/ -// i/o hookup is identical to Galaxian 2, so we can use those handlers +class epacman2_state : public egalaxn2_state +{ +public: + epacman2_state(const machine_config &mconfig, device_type type, const char *tag) + : egalaxn2_state(mconfig, type, tag) + { } + +}; + +// handlers are identical to Galaxian 2, so we can use those + +// config static INPUT_PORTS_START( epacman2 ) PORT_START("IN.0") // D1 port R0x @@ -1305,19 +1382,18 @@ static INPUT_PORTS_START( epacman2 ) PORT_CONFSETTING( 0x00, "2" ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( epacman2, hh_hmcs40_state ) +static MACHINE_CONFIG_START( epacman2, epacman2_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_READ_R_CB(0, READ8(hh_hmcs40_state, egalaxn2_input_r)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, egalaxn2_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, egalaxn2_grid_w)) + MCFG_HMCS40_READ_R_CB(0, READ8(egalaxn2_state, input_r)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(egalaxn2_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(egalaxn2_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -1344,7 +1420,20 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_hmcs40_state::pbqbert_plate_w) +class pbqbert_state : public hh_hmcs40_state +{ +public: + pbqbert_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); +}; + +// handlers + +WRITE8_MEMBER(pbqbert_state::plate_w) { // R0x-R6x,D8: vfd matrix plate int shift = offset * 4; @@ -1352,11 +1441,10 @@ WRITE8_MEMBER(hh_hmcs40_state::pbqbert_plate_w) // update display UINT32 plate = BITSWAP32(m_plate,31,30,24,25,26,27,28,15,14,29,13,12,11,10,9,8,7,6,5,4,3,2,1,0,16,17,18,19,20,21,22,23); - display_matrix(30, 8, plate, m_grid); } -WRITE16_MEMBER(hh_hmcs40_state::pbqbert_grid_w) +WRITE16_MEMBER(pbqbert_state::grid_w) { // D14: speaker out m_speaker->level_w(data >> 14 & 1); @@ -1365,10 +1453,12 @@ WRITE16_MEMBER(hh_hmcs40_state::pbqbert_grid_w) m_grid = data & 0xff; // D8: plate 25 (update display there) - pbqbert_plate_w(space, 7, data >> 8 & 1); + plate_w(space, 7, data >> 8 & 1); } +// config + static INPUT_PORTS_START( pbqbert ) PORT_START("IN.0") // port D PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) // up-left @@ -1378,19 +1468,18 @@ static INPUT_PORTS_START( pbqbert ) PORT_BIT( 0xe1ff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( pbqbert, hh_hmcs40_state ) +static MACHINE_CONFIG_START( pbqbert, pbqbert_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38820, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_R_CB(4, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_R_CB(5, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_R_CB(6, WRITE8(hh_hmcs40_state, pbqbert_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, pbqbert_grid_w)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(4, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(5, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(6, WRITE8(pbqbert_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(pbqbert_state, grid_w)) MCFG_HMCS40_READ_D_CB(IOPORT("IN.0")) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) @@ -1419,24 +1508,39 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_hmcs40_state::kingman_display() +class kingman_state : public hh_hmcs40_state +{ +public: + kingman_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + void kingman_display(); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + + void update_int0(); + DECLARE_INPUT_CHANGED_MEMBER(input_changed); +}; + +// handlers + +void kingman_state::kingman_display() { UINT16 grid = BITSWAP16(m_grid,15,14,13,12,11,10,9,0,1,2,3,4,5,6,7,8); UINT32 plate = BITSWAP24(m_plate,23,6,7,5,4,3,2,1,0,13,12,20,19,18,17,16,10,11,9,8,14,15,13,12); - display_matrix(23, 9, plate, grid); } -WRITE8_MEMBER(hh_hmcs40_state::kingman_plate_w) +WRITE8_MEMBER(kingman_state::plate_w) { // R0x-R3x: vfd matrix plate int shift = offset * 4; m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - kingman_display(); } -WRITE16_MEMBER(hh_hmcs40_state::kingman_grid_w) +WRITE16_MEMBER(kingman_state::grid_w) { // D6: speaker out m_speaker->level_w(data >> 6 & 1); @@ -1446,7 +1550,7 @@ WRITE16_MEMBER(hh_hmcs40_state::kingman_grid_w) if (inp_mux != m_inp_mux) { m_inp_mux = inp_mux; - kingman_update_int0(); + update_int0(); } // D7-D15: vfd matrix grid @@ -1457,47 +1561,47 @@ WRITE16_MEMBER(hh_hmcs40_state::kingman_grid_w) kingman_display(); } -void hh_hmcs40_state::kingman_update_int0() +void kingman_state::update_int0() { // INT0 on multiplexed inputs set_interrupt(0, read_inputs(4)); } -INPUT_CHANGED_MEMBER(hh_hmcs40_state::kingman_input_changed) -{ - kingman_update_int0(); -} +// config static INPUT_PORTS_START( kingman ) PORT_START("IN.0") // D12 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, kingman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, kingman_state, input_changed, NULL) PORT_START("IN.1") // D13 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, kingman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, kingman_state, input_changed, NULL) PORT_START("IN.2") // D14 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, kingman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, kingman_state, input_changed, NULL) PORT_START("IN.3") // D15 INT0 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, kingman_input_changed, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, kingman_state, input_changed, NULL) PORT_START("IN.4") // INT1 PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)1) - - INPUT_PORTS_END +INPUT_CHANGED_MEMBER(kingman_state::input_changed) +{ + update_int0(); +} -static MACHINE_CONFIG_START( kingman, hh_hmcs40_state ) + +static MACHINE_CONFIG_START( kingman, kingman_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38800, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, kingman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, kingman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, kingman_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, kingman_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, kingman_grid_w)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(kingman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(kingman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(kingman_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(kingman_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(kingman_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) @@ -1525,24 +1629,39 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_hmcs40_state::tmtron_display() +class tmtron_state : public hh_hmcs40_state +{ +public: + tmtron_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_hmcs40_state(mconfig, type, tag) + { } + + void tmtron_display(); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE16_MEMBER(grid_w); + + void update_int1(); + DECLARE_INPUT_CHANGED_MEMBER(input_changed); +}; + +// handlers + +void tmtron_state::tmtron_display() { UINT16 grid = BITSWAP16(m_grid,15,14,13,12,11,10,1,2,3,4,5,6,7,8,9,0); UINT32 plate = BITSWAP24(m_plate,23,5,2,21,1,6,7,9,10,11,21,0,19,3,4,8,3,18,17,16,12,13,14,15); - display_matrix(23, 10, plate, grid); } -WRITE8_MEMBER(hh_hmcs40_state::tmtron_plate_w) +WRITE8_MEMBER(tmtron_state::plate_w) { // R0x-R3x: vfd matrix plate int shift = offset * 4; m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - tmtron_display(); } -WRITE16_MEMBER(hh_hmcs40_state::tmtron_grid_w) +WRITE16_MEMBER(tmtron_state::grid_w) { // D4: speaker out m_speaker->level_w(data >> 4 & 1); @@ -1552,7 +1671,7 @@ WRITE16_MEMBER(hh_hmcs40_state::tmtron_grid_w) if (inp_mux != m_inp_mux) { m_inp_mux = inp_mux; - tmtron_update_int1(); + update_int1(); } // D6-D15: vfd matrix grid @@ -1563,45 +1682,47 @@ WRITE16_MEMBER(hh_hmcs40_state::tmtron_grid_w) tmtron_display(); } - -void hh_hmcs40_state::tmtron_update_int1() +void tmtron_state::update_int1() { // INT1 on multiplexed inputs set_interrupt(1, read_inputs(4)); } -INPUT_CHANGED_MEMBER(hh_hmcs40_state::tmtron_input_changed) -{ - tmtron_update_int1(); -} + +// config static INPUT_PORTS_START( tmtron ) PORT_START("IN.0") // D12 INT1 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, tmtron_input_changed, NULL) PORT_16WAY // separate directional buttons, hence 16way + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtron_state, input_changed, NULL) PORT_16WAY // separate directional buttons, hence 16way PORT_START("IN.1") // D13 INT1 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, tmtron_input_changed, NULL) PORT_16WAY // " + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtron_state, input_changed, NULL) PORT_16WAY // " PORT_START("IN.2") // D14 INT1 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, tmtron_input_changed, NULL) PORT_16WAY // " + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtron_state, input_changed, NULL) PORT_16WAY // " PORT_START("IN.3") // D15 INT1 - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, tmtron_input_changed, NULL) PORT_16WAY // " + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtron_state, input_changed, NULL) PORT_16WAY // " PORT_START("IN.4") // INT0 PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_hmcs40_state, single_interrupt_line, (void *)0) INPUT_PORTS_END +INPUT_CHANGED_MEMBER(tmtron_state::input_changed) +{ + update_int1(); +} -static MACHINE_CONFIG_START( tmtron, hh_hmcs40_state ) + +static MACHINE_CONFIG_START( tmtron, tmtron_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", HD38800, 400000) // approximation - RC osc. - MCFG_HMCS40_WRITE_R_CB(0, WRITE8(hh_hmcs40_state, tmtron_plate_w)) - MCFG_HMCS40_WRITE_R_CB(1, WRITE8(hh_hmcs40_state, tmtron_plate_w)) - MCFG_HMCS40_WRITE_R_CB(2, WRITE8(hh_hmcs40_state, tmtron_plate_w)) - MCFG_HMCS40_WRITE_R_CB(3, WRITE8(hh_hmcs40_state, tmtron_plate_w)) - MCFG_HMCS40_WRITE_D_CB(WRITE16(hh_hmcs40_state, tmtron_grid_w)) + MCFG_HMCS40_WRITE_R_CB(0, WRITE8(tmtron_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(1, WRITE8(tmtron_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(2, WRITE8(tmtron_state, plate_w)) + MCFG_HMCS40_WRITE_R_CB(3, WRITE8(tmtron_state, plate_w)) + MCFG_HMCS40_WRITE_D_CB(WRITE16(tmtron_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_hmcs40_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_hmcs40_test) diff --git a/src/mess/drivers/hh_pic16.c b/src/mess/drivers/hh_pic16.c index 07edf6a32e5..77d29015073 100644 --- a/src/mess/drivers/hh_pic16.c +++ b/src/mess/drivers/hh_pic16.c @@ -51,8 +51,6 @@ public: UINT8 m_b; // MCU port B data UINT8 m_c; // MCU port C data - virtual void machine_start(); - // display common int m_display_wait; // led/lamp off-delay in microseconds (default 33ms) int m_display_maxy; // display matrix number of rows @@ -68,11 +66,14 @@ public: void set_display_size(int maxx, int maxy); void display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety); - // game-specific handlers - DECLARE_WRITE8_MEMBER(maniac_output_w); +protected: + virtual void machine_start(); + virtual void machine_reset(); }; +// machine start/reset + void hh_pic16_state::machine_start() { // zerofill @@ -98,6 +99,10 @@ void hh_pic16_state::machine_start() save_item(NAME(m_c)); } +void hh_pic16_state::machine_reset() +{ +} + /*************************************************************************** @@ -124,7 +129,7 @@ void hh_pic16_state::display_update() m_display_decay[y][x] = m_display_wait; // determine active state - int ds = (m_display_decay[y][x] != 0) ? 1 : 0; + UINT32 ds = (m_display_decay[y][x] != 0) ? 1 : 0; active_state[y] |= (ds << x); } } @@ -195,7 +200,7 @@ void hh_pic16_state::display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety /*************************************************************************** - Minidrivers (I/O, Inputs, Machine Config) + Minidrivers (subclass, I/O, Inputs, Machine Config) ***************************************************************************/ @@ -207,7 +212,19 @@ void hh_pic16_state::display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety ***************************************************************************/ -WRITE8_MEMBER(hh_pic16_state::maniac_output_w) +class maniac_state : public hh_pic16_state +{ +public: + maniac_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_pic16_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(output_w); +}; + +// handlers + +WRITE8_MEMBER(maniac_state::output_w) { // B,C: outputs offset -= PIC16C5x_PORTB; @@ -228,6 +245,8 @@ WRITE8_MEMBER(hh_pic16_state::maniac_output_w) } +// config + static INPUT_PORTS_START( maniac ) PORT_START("IN.0") // port A PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // bottom-right @@ -239,13 +258,13 @@ INPUT_PORTS_END static const INT16 maniac_speaker_levels[] = { 0, 32767, -32768, 0 }; -static MACHINE_CONFIG_START( maniac, hh_pic16_state ) +static MACHINE_CONFIG_START( maniac, maniac_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", PIC16C55, 850000) // RC osc. R=13.4K, C=470pf, but unknown RC curve - measured 800-890kHz MCFG_PIC16C5x_READ_A_CB(IOPORT("IN.0")) - MCFG_PIC16C5x_WRITE_B_CB(WRITE8(hh_pic16_state, maniac_output_w)) - MCFG_PIC16C5x_WRITE_C_CB(WRITE8(hh_pic16_state, maniac_output_w)) + MCFG_PIC16C5x_WRITE_B_CB(WRITE8(maniac_state, output_w)) + MCFG_PIC16C5x_WRITE_C_CB(WRITE8(maniac_state, output_w)) MCFG_PIC16C5x_SET_CONFIG(0) // ? MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_pic16_state, display_decay_tick, attotime::from_msec(1)) diff --git a/src/mess/drivers/hh_tms1k.c b/src/mess/drivers/hh_tms1k.c index 8937ce30f21..cb00cf87eac 100644 --- a/src/mess/drivers/hh_tms1k.c +++ b/src/mess/drivers/hh_tms1k.c @@ -161,7 +161,7 @@ void hh_tms1k_state::display_update() m_display_decay[y][x] = m_display_wait; // determine active state - int ds = (m_display_decay[y][x] != 0) ? 1 : 0; + UINT32 ds = (m_display_decay[y][x] != 0) ? 1 : 0; active_state[y] |= (ds << x); } } @@ -228,6 +228,15 @@ void hh_tms1k_state::display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety display_update(); } +void hh_tms1k_state::display_matrix_seg(int maxx, int maxy, UINT32 setx, UINT32 sety, UINT16 segmask) +{ + // expects m_display_segmask to be not-0 + for (int y = 0; y < maxy; y++) + m_display_segmask[y] &= segmask; + + display_matrix(maxx, maxy, setx, sety); +} + UINT8 hh_tms1k_state::read_inputs(int columns) { diff --git a/src/mess/drivers/hh_ucom4.c b/src/mess/drivers/hh_ucom4.c index 69e5f4f2d84..778b019c12f 100644 --- a/src/mess/drivers/hh_ucom4.c +++ b/src/mess/drivers/hh_ucom4.c @@ -54,13 +54,11 @@ public: optional_device m_speaker; // misc common - UINT8 m_port[9]; // MCU port A-I write data + UINT8 m_port[9]; // MCU port A-I write data (optional) UINT16 m_inp_mux; // multiplexed inputs mask UINT8 read_inputs(int columns); - virtual void machine_start(); - // display common int m_display_wait; // led/lamp off-delay in microseconds (default 33ms) int m_display_maxy; // display matrix number of rows @@ -79,41 +77,14 @@ public: void set_display_size(int maxx, int maxy); void display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety); - // game-specific handlers - void ssfball_display(); - DECLARE_WRITE8_MEMBER(ssfball_grid_w); - DECLARE_WRITE8_MEMBER(ssfball_plate_w); - DECLARE_READ8_MEMBER(ssfball_input_b_r); - - void splasfgt_display(); - DECLARE_WRITE8_MEMBER(splasfgt_grid_w); - DECLARE_WRITE8_MEMBER(splasfgt_plate_w); - DECLARE_READ8_MEMBER(splasfgt_input_b_r); - - void astrocmd_display(); - DECLARE_WRITE8_MEMBER(astrocmd_grid_w); - DECLARE_WRITE8_MEMBER(astrocmd_plate_w); - - DECLARE_WRITE8_MEMBER(edracula_grid_w); - DECLARE_WRITE8_MEMBER(edracula_plate_w); - - DECLARE_WRITE8_MEMBER(tmtennis_grid_w); - DECLARE_WRITE8_MEMBER(tmtennis_plate_w); - DECLARE_WRITE8_MEMBER(tmtennis_port_e_w); - DECLARE_READ8_MEMBER(tmtennis_input_r); - void tmtennis_set_clock(); - DECLARE_INPUT_CHANGED_MEMBER(tmtennis_difficulty_switch); - DECLARE_MACHINE_RESET(tmtennis); - - void tmpacman_display(); - DECLARE_WRITE8_MEMBER(tmpacman_grid_w); - DECLARE_WRITE8_MEMBER(tmpacman_plate_w); - - DECLARE_WRITE8_MEMBER(alnchase_output_w); - DECLARE_READ8_MEMBER(alnchase_input_r); +protected: + virtual void machine_start(); + virtual void machine_reset(); }; +// machine start/reset + void hh_ucom4_state::machine_start() { // zerofill @@ -143,6 +114,10 @@ void hh_ucom4_state::machine_start() save_item(NAME(m_plate)); } +void hh_ucom4_state::machine_reset() +{ +} + /*************************************************************************** @@ -169,7 +144,7 @@ void hh_ucom4_state::display_update() m_display_decay[y][x] = m_display_wait; // determine active state - int ds = (m_display_decay[y][x] != 0) ? 1 : 0; + UINT32 ds = (m_display_decay[y][x] != 0) ? 1 : 0; active_state[y] |= (ds << x); } } @@ -253,7 +228,7 @@ UINT8 hh_ucom4_state::read_inputs(int columns) /*************************************************************************** - Minidrivers (I/O, Inputs, Machine Config) + Minidrivers (subclass, I/O, Inputs, Machine Config) ***************************************************************************/ @@ -272,23 +247,36 @@ UINT8 hh_ucom4_state::read_inputs(int columns) ***************************************************************************/ -void hh_ucom4_state::ssfball_display() +class ssfball_state : public hh_ucom4_state +{ +public: + ssfball_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + void ssfball_display(); + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_READ8_MEMBER(input_b_r); +}; + +// handlers + +void ssfball_state::ssfball_display() { UINT32 plate = BITSWAP24(m_plate,23,22,21,20,19,11,7,3,12,17,13,18,16,14,15,10,9,8,0,1,2,4,5,6); - display_matrix(16, 9, plate, m_grid); } -WRITE8_MEMBER(hh_ucom4_state::ssfball_grid_w) +WRITE8_MEMBER(ssfball_state::grid_w) { - // C,D(,E): vfd matrix grid 0-7(,8) + // C,D(,E3): vfd matrix grid 0-7(,8) int shift = (offset - NEC_UCOM4_PORTC) * 4; m_grid = (m_grid & ~(0xf << shift)) | (data << shift); - ssfball_display(); } -WRITE8_MEMBER(hh_ucom4_state::ssfball_plate_w) +WRITE8_MEMBER(ssfball_state::plate_w) { m_port[offset] = data; @@ -302,18 +290,20 @@ WRITE8_MEMBER(hh_ucom4_state::ssfball_plate_w) // E3: vfd matrix grid 8 if (offset == NEC_UCOM4_PORTE) - ssfball_grid_w(space, offset, data >> 3 & 1); + grid_w(space, offset, data >> 3 & 1); else ssfball_display(); } -READ8_MEMBER(hh_ucom4_state::ssfball_input_b_r) +READ8_MEMBER(ssfball_state::input_b_r) { // B: input port 2, where B3 is multiplexed return m_inp_matrix[2]->read() | read_inputs(2); } +// config + static INPUT_PORTS_START( ssfball ) PORT_START("IN.0") // F3 port B3 PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_UNUSED ) @@ -341,19 +331,19 @@ INPUT_PORTS_END static const INT16 ssfball_speaker_levels[] = { 0, 32767, -32768, 0 }; -static MACHINE_CONFIG_START( ssfball, hh_ucom4_state ) +static MACHINE_CONFIG_START( ssfball, ssfball_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", NEC_D553, XTAL_400kHz) MCFG_UCOM4_READ_A_CB(IOPORT("IN.3")) - MCFG_UCOM4_READ_B_CB(READ8(hh_ucom4_state, ssfball_input_b_r)) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, ssfball_grid_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, ssfball_grid_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, ssfball_plate_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, ssfball_plate_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, ssfball_plate_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, ssfball_plate_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, ssfball_plate_w)) + MCFG_UCOM4_READ_B_CB(READ8(ssfball_state, input_b_r)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(ssfball_state, grid_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(ssfball_state, grid_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(ssfball_state, plate_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(ssfball_state, plate_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(ssfball_state, plate_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(ssfball_state, plate_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(ssfball_state, plate_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) @@ -382,14 +372,28 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_ucom4_state::splasfgt_display() +class splasfgt_state : public hh_ucom4_state +{ +public: + splasfgt_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + void splasfgt_display(); + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_READ8_MEMBER(input_b_r); +}; + +// handlers + +void splasfgt_state::splasfgt_display() { UINT32 plate = BITSWAP24(m_plate,23,22,21,20,19,18,17,13,1,0,8,6,0,10,11,14,15,16,9,5,7,4,2,3); - display_matrix(16, 9, plate, m_grid); } -WRITE8_MEMBER(hh_ucom4_state::splasfgt_grid_w) +WRITE8_MEMBER(splasfgt_state::grid_w) { // G,H,I0: vfd matrix grid int shift = (offset - NEC_UCOM4_PORTG) * 4; @@ -400,31 +404,32 @@ WRITE8_MEMBER(hh_ucom4_state::splasfgt_grid_w) // I2: vfd matrix plate 6 if (offset == NEC_UCOM4_PORTI) - m_plate = (m_plate & 0xffff) | (data << 14 & 0x10000); - - splasfgt_display(); + plate_w(space, 4 + NEC_UCOM4_PORTC, data >> 2 & 1); + else + splasfgt_display(); } -WRITE8_MEMBER(hh_ucom4_state::splasfgt_plate_w) +WRITE8_MEMBER(splasfgt_state::plate_w) { - // C,D,E,F23: vfd matrix plate - int shift = (offset - NEC_UCOM4_PORTC) * 4; - m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - // F01: speaker out if (offset == NEC_UCOM4_PORTF) m_speaker->level_w(data & 3); - ssfball_display(); + // C,D,E,F23(,I2): vfd matrix plate + int shift = (offset - NEC_UCOM4_PORTC) * 4; + m_plate = (m_plate & ~(0xf << shift)) | (data << shift); + splasfgt_display(); } -READ8_MEMBER(hh_ucom4_state::splasfgt_input_b_r) +READ8_MEMBER(splasfgt_state::input_b_r) { // B: multiplexed buttons return read_inputs(4); } +// config + /* physical button layout and labels is like this: * left = P1 side * * right = P2 side * (note: in 1P mode, switch sides between turns) @@ -475,19 +480,19 @@ INPUT_PORTS_END static const INT16 splasfgt_speaker_levels[] = { 0, 32767, -32768, 0 }; -static MACHINE_CONFIG_START( splasfgt, hh_ucom4_state ) +static MACHINE_CONFIG_START( splasfgt, splasfgt_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", NEC_D553, XTAL_400kHz) MCFG_UCOM4_READ_A_CB(IOPORT("IN.4")) - MCFG_UCOM4_READ_B_CB(READ8(hh_ucom4_state, splasfgt_input_b_r)) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, splasfgt_plate_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, splasfgt_plate_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, splasfgt_plate_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, splasfgt_plate_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, splasfgt_grid_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, splasfgt_grid_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, splasfgt_grid_w)) + MCFG_UCOM4_READ_B_CB(READ8(splasfgt_state, input_b_r)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(splasfgt_state, plate_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(splasfgt_state, plate_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(splasfgt_state, plate_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(splasfgt_state, plate_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(splasfgt_state, grid_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(splasfgt_state, grid_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(splasfgt_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) @@ -521,24 +526,36 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_ucom4_state::astrocmd_display() +class astrocmd_state : public hh_ucom4_state +{ +public: + astrocmd_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + void astrocmd_display(); + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_WRITE8_MEMBER(plate_w); +}; + +// handlers + +void astrocmd_state::astrocmd_display() { UINT16 grid = BITSWAP16(m_grid,15,14,13,12,11,10,9,8,4,5,6,7,0,1,2,3); UINT32 plate = BITSWAP24(m_plate,23,22,21,20,19,3,2,12,13,14,15,16,17,18,0,1,4,8,5,9,7,11,6,10); - display_matrix(17, 9, plate, grid); } -WRITE8_MEMBER(hh_ucom4_state::astrocmd_grid_w) +WRITE8_MEMBER(astrocmd_state::grid_w) { // C,D(,E3): vfd matrix grid int shift = (offset - NEC_UCOM4_PORTC) * 4; m_grid = (m_grid & ~(0xf << shift)) | (data << shift); - astrocmd_display(); } -WRITE8_MEMBER(hh_ucom4_state::astrocmd_plate_w) +WRITE8_MEMBER(astrocmd_state::plate_w) { // E01,F,G,H,I: vfd matrix plate int shift = (offset - NEC_UCOM4_PORTE) * 4; @@ -550,13 +567,15 @@ WRITE8_MEMBER(hh_ucom4_state::astrocmd_plate_w) m_speaker->level_w(data >> 2 & 1); // E3: vfd matrix grid 8 - astrocmd_grid_w(space, offset, data >> 3 & 1); + grid_w(space, offset, data >> 3 & 1); } else astrocmd_display(); } +// config + static INPUT_PORTS_START( astrocmd ) PORT_START("IN.0") // port A PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SELECT ) @@ -571,20 +590,19 @@ static INPUT_PORTS_START( astrocmd ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( astrocmd, hh_ucom4_state ) +static MACHINE_CONFIG_START( astrocmd, astrocmd_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", NEC_D553, XTAL_400kHz) MCFG_UCOM4_READ_A_CB(IOPORT("IN.0")) MCFG_UCOM4_READ_B_CB(IOPORT("IN.1")) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, astrocmd_grid_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, astrocmd_grid_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, astrocmd_plate_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, astrocmd_plate_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, astrocmd_plate_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, astrocmd_plate_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, astrocmd_plate_w)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(astrocmd_state, grid_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(astrocmd_state, grid_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(astrocmd_state, plate_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(astrocmd_state, plate_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(astrocmd_state, plate_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(astrocmd_state, plate_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(astrocmd_state, plate_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) @@ -617,16 +635,28 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_ucom4_state::edracula_grid_w) +class edracula_state : public hh_ucom4_state +{ +public: + edracula_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_WRITE8_MEMBER(plate_w); +}; + +// handlers + +WRITE8_MEMBER(edracula_state::grid_w) { // C,D: vfd matrix grid int shift = (offset - NEC_UCOM4_PORTC) * 4; m_grid = (m_grid & ~(0xf << shift)) | (data << shift); - - display_matrix(18+1, 8, m_plate, m_grid); + display_matrix(18, 8, m_plate, m_grid); } -WRITE8_MEMBER(hh_ucom4_state::edracula_plate_w) +WRITE8_MEMBER(edracula_state::plate_w) { // I2: speaker out if (offset == NEC_UCOM4_PORTI) @@ -635,11 +665,12 @@ WRITE8_MEMBER(hh_ucom4_state::edracula_plate_w) // E,F,G,H,I01: vfd matrix plate int shift = (offset - NEC_UCOM4_PORTE) * 4; m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - display_matrix(18, 8, m_plate, m_grid); } +// config + static INPUT_PORTS_START( edracula ) PORT_START("IN.0") // port A PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SELECT ) @@ -654,20 +685,19 @@ static INPUT_PORTS_START( edracula ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( edracula, hh_ucom4_state ) +static MACHINE_CONFIG_START( edracula, edracula_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", NEC_D553, XTAL_400kHz) MCFG_UCOM4_READ_A_CB(IOPORT("IN.0")) MCFG_UCOM4_READ_B_CB(IOPORT("IN.1")) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, edracula_grid_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, edracula_grid_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, edracula_plate_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, edracula_plate_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, edracula_plate_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, edracula_plate_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, edracula_plate_w)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(edracula_state, grid_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(edracula_state, grid_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(edracula_state, plate_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(edracula_state, plate_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(edracula_state, plate_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(edracula_state, plate_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(edracula_state, plate_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) @@ -701,26 +731,45 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_ucom4_state::tmtennis_grid_w) +class tmtennis_state : public hh_ucom4_state +{ +public: + tmtennis_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_WRITE8_MEMBER(plate_w); + DECLARE_WRITE8_MEMBER(port_e_w); + DECLARE_READ8_MEMBER(input_r); + + void set_clock(); + DECLARE_INPUT_CHANGED_MEMBER(difficulty_switch); + +protected: + virtual void machine_reset(); +}; + +// handlers + +WRITE8_MEMBER(tmtennis_state::grid_w) { // G,H,I: vfd matrix grid int shift = (offset - NEC_UCOM4_PORTG) * 4; m_grid = (m_grid & ~(0xf << shift)) | (data << shift); - display_matrix(12, 12, m_plate, m_grid); } -WRITE8_MEMBER(hh_ucom4_state::tmtennis_plate_w) +WRITE8_MEMBER(tmtennis_state::plate_w) { // C,D,F: vfd matrix plate if (offset == NEC_UCOM4_PORTF) offset--; int shift = (offset - NEC_UCOM4_PORTC) * 4; m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - display_matrix(12, 12, m_plate, m_grid); } -WRITE8_MEMBER(hh_ucom4_state::tmtennis_port_e_w) +WRITE8_MEMBER(tmtennis_state::port_e_w) { // E01: input mux // E2: speaker out @@ -729,13 +778,15 @@ WRITE8_MEMBER(hh_ucom4_state::tmtennis_port_e_w) m_speaker->level_w(data >> 2 & 1); } -READ8_MEMBER(hh_ucom4_state::tmtennis_input_r) +READ8_MEMBER(tmtennis_state::input_r) { // A,B: multiplexed buttons return ~read_inputs(2) >> (offset*4); } +// config + /* Pro-Tennis physical button layout and labels is like this: * left = P2/CPU side * * right = P1 side * @@ -758,9 +809,9 @@ static INPUT_PORTS_START( tmtennis ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_J) PORT_NAME("P1 Button 6") PORT_START("IN.1") // E1 port A/B - PORT_CONFNAME( 0x101, 0x100, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, hh_ucom4_state, tmtennis_difficulty_switch, NULL) + PORT_CONFNAME( 0x101, 0x100, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtennis_state, difficulty_switch, NULL) PORT_CONFSETTING( 0x001, "Practice" ) - PORT_CONFSETTING( 0x100, "Pro 1" ) // -> tmtennis_difficulty_switch + PORT_CONFSETTING( 0x100, "Pro 1" ) // -> difficulty_switch PORT_CONFSETTING( 0x000, "Pro 2" ) PORT_CONFNAME( 0x02, 0x00, "Players" ) PORT_CONFSETTING( 0x00, "1" ) @@ -773,8 +824,13 @@ static INPUT_PORTS_START( tmtennis ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_D) PORT_NAME("P2 Button 6") INPUT_PORTS_END +INPUT_CHANGED_MEMBER(tmtennis_state::difficulty_switch) +{ + set_clock(); +} -void hh_ucom4_state::tmtennis_set_clock() + +void tmtennis_state::set_clock() { // MCU clock is from an LC circuit oscillating by default at ~360kHz, // but on PRO1, the difficulty switch puts a capacitor across the LC circuit @@ -782,35 +838,29 @@ void hh_ucom4_state::tmtennis_set_clock() m_maincpu->set_unscaled_clock((m_inp_matrix[1]->read() & 0x100) ? 260000 : 360000); } -INPUT_CHANGED_MEMBER(hh_ucom4_state::tmtennis_difficulty_switch) +void tmtennis_state::machine_reset() { - tmtennis_set_clock(); + hh_ucom4_state::machine_reset(); + set_clock(); } -MACHINE_RESET_MEMBER(hh_ucom4_state, tmtennis) -{ - tmtennis_set_clock(); -} - -static MACHINE_CONFIG_START( tmtennis, hh_ucom4_state ) +static MACHINE_CONFIG_START( tmtennis, tmtennis_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", NEC_D552, 360000) // see tmtennis_set_clock - MCFG_UCOM4_READ_A_CB(READ8(hh_ucom4_state, tmtennis_input_r)) - MCFG_UCOM4_READ_B_CB(READ8(hh_ucom4_state, tmtennis_input_r)) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, tmtennis_plate_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, tmtennis_plate_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, tmtennis_port_e_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, tmtennis_plate_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, tmtennis_grid_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, tmtennis_grid_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, tmtennis_grid_w)) + MCFG_CPU_ADD("maincpu", NEC_D552, 360000) // see set_clock + MCFG_UCOM4_READ_A_CB(READ8(tmtennis_state, input_r)) + MCFG_UCOM4_READ_B_CB(READ8(tmtennis_state, input_r)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(tmtennis_state, plate_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(tmtennis_state, plate_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(tmtennis_state, port_e_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(tmtennis_state, plate_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(tmtennis_state, grid_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(tmtennis_state, grid_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(tmtennis_state, grid_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) - MCFG_MACHINE_RESET_OVERRIDE(hh_ucom4_state, tmtennis) - /* no video! */ /* sound hardware */ @@ -844,24 +894,36 @@ MACHINE_CONFIG_END ***************************************************************************/ -void hh_ucom4_state::tmpacman_display() +class tmpacman_state : public hh_ucom4_state +{ +public: + tmpacman_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + void tmpacman_display(); + DECLARE_WRITE8_MEMBER(grid_w); + DECLARE_WRITE8_MEMBER(plate_w); +}; + +// handlers + +void tmpacman_state::tmpacman_display() { UINT16 grid = BITSWAP8(m_grid,0,1,2,3,4,5,6,7); UINT32 plate = BITSWAP24(m_plate,23,22,21,20,19,16,17,18,11,10,9,8,0,2,3,1,4,5,6,7,12,13,14,15); - display_matrix(19, 8, plate, grid); } -WRITE8_MEMBER(hh_ucom4_state::tmpacman_grid_w) +WRITE8_MEMBER(tmpacman_state::grid_w) { // C,D: vfd matrix grid int shift = (offset - NEC_UCOM4_PORTC) * 4; m_grid = (m_grid & ~(0xf << shift)) | (data << shift); - tmpacman_display(); } -WRITE8_MEMBER(hh_ucom4_state::tmpacman_plate_w) +WRITE8_MEMBER(tmpacman_state::plate_w) { // E1: speaker out if (offset == NEC_UCOM4_PORTE) @@ -870,11 +932,12 @@ WRITE8_MEMBER(hh_ucom4_state::tmpacman_plate_w) // E023,F,G,H,I: vfd matrix plate int shift = (offset - NEC_UCOM4_PORTE) * 4; m_plate = (m_plate & ~(0xf << shift)) | (data << shift); - tmpacman_display(); } +// config + static INPUT_PORTS_START( tmpacman ) PORT_START("IN.0") // port A PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_16WAY // separate directional buttons, hence 16way @@ -889,20 +952,19 @@ static INPUT_PORTS_START( tmpacman ) PORT_BIT( 0x0e, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( tmpacman, hh_ucom4_state ) +static MACHINE_CONFIG_START( tmpacman, tmpacman_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", NEC_D553, XTAL_430kHz) MCFG_UCOM4_READ_A_CB(IOPORT("IN.0")) MCFG_UCOM4_READ_B_CB(IOPORT("IN.1")) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, tmpacman_grid_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, tmpacman_grid_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, tmpacman_plate_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, tmpacman_plate_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, tmpacman_plate_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, tmpacman_plate_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, tmpacman_plate_w)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(tmpacman_state, grid_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(tmpacman_state, grid_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(tmpacman_state, plate_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(tmpacman_state, plate_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(tmpacman_state, plate_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(tmpacman_state, plate_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(tmpacman_state, plate_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) @@ -937,7 +999,20 @@ MACHINE_CONFIG_END ***************************************************************************/ -WRITE8_MEMBER(hh_ucom4_state::alnchase_output_w) +class alnchase_state : public hh_ucom4_state +{ +public: + alnchase_state(const machine_config &mconfig, device_type type, const char *tag) + : hh_ucom4_state(mconfig, type, tag) + { } + + DECLARE_WRITE8_MEMBER(output_w); + DECLARE_READ8_MEMBER(input_r); +}; + +// handlers + +WRITE8_MEMBER(alnchase_state::output_w) { if (offset <= NEC_UCOM4_PORTE) { @@ -964,13 +1039,15 @@ WRITE8_MEMBER(hh_ucom4_state::alnchase_output_w) display_matrix(17, 9, m_plate, m_grid); } -READ8_MEMBER(hh_ucom4_state::alnchase_input_r) +READ8_MEMBER(alnchase_state::input_r) { // A: buttons return read_inputs(2); } +// config + /* physical button layout and labels is like this: POWER SOUND LEVEL PLAYER @@ -1008,20 +1085,19 @@ static INPUT_PORTS_START( alnchase ) PORT_BIT( 0x0c, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END - -static MACHINE_CONFIG_START( alnchase, hh_ucom4_state ) +static MACHINE_CONFIG_START( alnchase, alnchase_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", NEC_D553, XTAL_400kHz) - MCFG_UCOM4_READ_A_CB(READ8(hh_ucom4_state, alnchase_input_r)) + MCFG_UCOM4_READ_A_CB(READ8(alnchase_state, input_r)) MCFG_UCOM4_READ_B_CB(IOPORT("IN.2")) - MCFG_UCOM4_WRITE_C_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) - MCFG_UCOM4_WRITE_D_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) - MCFG_UCOM4_WRITE_E_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) - MCFG_UCOM4_WRITE_F_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) - MCFG_UCOM4_WRITE_G_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) - MCFG_UCOM4_WRITE_H_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) - MCFG_UCOM4_WRITE_I_CB(WRITE8(hh_ucom4_state, alnchase_output_w)) + MCFG_UCOM4_WRITE_C_CB(WRITE8(alnchase_state, output_w)) + MCFG_UCOM4_WRITE_D_CB(WRITE8(alnchase_state, output_w)) + MCFG_UCOM4_WRITE_E_CB(WRITE8(alnchase_state, output_w)) + MCFG_UCOM4_WRITE_F_CB(WRITE8(alnchase_state, output_w)) + MCFG_UCOM4_WRITE_G_CB(WRITE8(alnchase_state, output_w)) + MCFG_UCOM4_WRITE_H_CB(WRITE8(alnchase_state, output_w)) + MCFG_UCOM4_WRITE_I_CB(WRITE8(alnchase_state, output_w)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_ucom4_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_hh_ucom4_test) diff --git a/src/mess/drivers/ticalc1x.c b/src/mess/drivers/ticalc1x.c index b0e06af609d..81713a9f042 100644 --- a/src/mess/drivers/ticalc1x.c +++ b/src/mess/drivers/ticalc1x.c @@ -31,8 +31,6 @@ public: : hh_tms1k_state(mconfig, type, tag) { } - void display_matrix_seg(int maxx, int maxy, UINT32 setx, UINT32 sety, UINT16 segmask); - // calculator-specific handlers void tisr16_display(); DECLARE_WRITE16_MEMBER(tisr16_write_o); @@ -73,14 +71,6 @@ void ticalc1x_state::machine_start() memset(m_display_segmask, ~0, sizeof(m_display_segmask)); // ! } -void ticalc1x_state::display_matrix_seg(int maxx, int maxy, UINT32 setx, UINT32 sety, UINT16 segmask) -{ - for (int y = 0; y < maxy; y++) - m_display_segmask[y] &= segmask; - - display_matrix(maxx, maxy, setx, sety); -} - /*************************************************************************** diff --git a/src/mess/drivers/tispeak.c b/src/mess/drivers/tispeak.c index b206220f654..73992331fb3 100644 --- a/src/mess/drivers/tispeak.c +++ b/src/mess/drivers/tispeak.c @@ -314,6 +314,7 @@ public: // cartridge UINT32 m_cart_max_size; UINT8* m_cart_base; + void init_cartridge(); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(tispeak_cartridge); DECLARE_DRIVER_INIT(snspell); DECLARE_DRIVER_INIT(lantutor); @@ -333,13 +334,33 @@ protected: }; +void tispeak_state::machine_start() +{ + hh_tms1k_state::machine_start(); + memset(m_display_segmask, ~0, sizeof(m_display_segmask)); // ! + + init_cartridge(); +} + + /*************************************************************************** - File Handling + Cartridge Handling ***************************************************************************/ +void tispeak_state::init_cartridge() +{ + if (m_cart != NULL && m_cart->exists()) + { + astring region_tag; + memory_region *src = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); + if (src) + memcpy(m_cart_base, src->base(), src->bytes()); + } +} + DEVICE_IMAGE_LOAD_MEMBER(tispeak_state, tispeak_cartridge) { UINT32 size = m_cart->common_get_size("rom"); @@ -381,16 +402,7 @@ DRIVER_INIT_MEMBER(tispeak_state, lantutor) void tispeak_state::snspell_display() { - for (int y = 0; y < 16; y++) - m_display_segmask[y] = 0x3fff; - - display_matrix(16, 16, m_o, (m_r & 0x8000) ? (m_r & 0x21ff) : 0); -} - -READ8_MEMBER(tispeak_state::snspell_read_k) -{ - // note: the Vss row is always on - return m_inp_matrix[8]->read() | read_inputs(8); + display_matrix_seg(16, 16, m_o, (m_r & 0x8000) ? (m_r & 0x21ff) : 0, 0x3fff); } WRITE16_MEMBER(tispeak_state::snspell_write_r) @@ -414,6 +426,12 @@ WRITE16_MEMBER(tispeak_state::snspell_write_o) snspell_display(); } +READ8_MEMBER(tispeak_state::snspell_read_k) +{ + // note: the Vss row is always on + return m_inp_matrix[8]->read() | read_inputs(8); +} + void tispeak_state::snspell_power_off() { @@ -639,21 +657,6 @@ INPUT_PORTS_END ***************************************************************************/ -void tispeak_state::machine_start() -{ - hh_tms1k_state::machine_start(); - - // init cartridge - if (m_cart != NULL && m_cart->exists()) - { - astring region_tag; - memory_region *src = memregion(region_tag.cpy(m_cart->tag()).cat(GENERIC_ROM_REGION_TAG)); - if (src) - memcpy(m_cart_base, src->base(), src->bytes()); - } -} - - static MACHINE_CONFIG_START( snmath, tispeak_state ) /* basic machine hardware */ @@ -919,17 +922,18 @@ ROM_END -COMP( 1978, snspell, 0, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US, 1978 version/prototype)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) -COMP( 1979, snspella, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US, 1979 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM -COMP( 1980, snspellb, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US, 1980 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM -COMP( 1978, snspelluk, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (UK, 1978 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM -COMP( 1981, snspelluka, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (UK, 1981 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM -COMP( 1979, snspelljp, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM -COMP( 1980, ladictee, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "La Dictee Magique (France)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // doesn't work due to missing CD2702 MCU dump, German/Italian version has CD2702 too +/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY, FULLNAME, FLAGS */ +COMP( 1978, snspell, 0, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US, 1978 version/prototype)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) +COMP( 1979, snspella, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US, 1979 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM +COMP( 1980, snspellb, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (US, 1980 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM +COMP( 1978, snspelluk, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (UK, 1978 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM +COMP( 1981, snspelluka, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (UK, 1981 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM +COMP( 1979, snspelljp, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "Speak & Spell (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // incomplete dump, uses prototype MCU ROM +COMP( 1980, ladictee, snspell, 0, snspell, snspell, tispeak_state, snspell, "Texas Instruments", "La Dictee Magique (France)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) // doesn't work due to missing CD2702 MCU dump, German/Italian version has CD2702 too -COMP( 1986, snmath, 0, 0, snmath, snmath, driver_device, 0, "Texas Instruments", "Speak & Math (US, 1986 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) -COMP( 1980, snmathp, snmath, 0, snmath, snmath, driver_device, 0, "Texas Instruments", "Speak & Math (US, 1980 version/prototype)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) +COMP( 1986, snmath, 0, 0, snmath, snmath, driver_device, 0, "Texas Instruments", "Speak & Math (US, 1986 version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) +COMP( 1980, snmathp, snmath, 0, snmath, snmath, driver_device, 0, "Texas Instruments", "Speak & Math (US, 1980 version/prototype)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) -COMP( 1980, snread, 0, 0, snread, snread, tispeak_state, snspell, "Texas Instruments", "Speak & Read (US)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) +COMP( 1980, snread, 0, 0, snread, snread, tispeak_state, snspell, "Texas Instruments", "Speak & Read (US)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) -COMP( 1979, lantutor, 0, 0, lantutor, lantutor, tispeak_state, lantutor, "Texas Instruments", "Language Tutor (prototype)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) +COMP( 1979, lantutor, 0, 0, lantutor, lantutor, tispeak_state, lantutor, "Texas Instruments", "Language Tutor (prototype)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) diff --git a/src/mess/includes/hh_tms1k.h b/src/mess/includes/hh_tms1k.h index d7d83058d49..19699528b2c 100644 --- a/src/mess/includes/hh_tms1k.h +++ b/src/mess/includes/hh_tms1k.h @@ -57,6 +57,7 @@ public: void display_update(); void set_display_size(int maxx, int maxy); void display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety); + void display_matrix_seg(int maxx, int maxy, UINT32 setx, UINT32 sety, UINT16 segmask); // game-specific handlers void mathmagi_display();