From 910d2267cad32587d3f8fa19ff603e15d2f336cb Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 28 Feb 2018 21:19:37 +1100 Subject: Start squeezing out the poor-performing parts of the output_manager: * Turn deprecated declataion warnings on by default and make them non-fatal * Make output_finder iterable in algorithms and range-based for loops * Replace a lot of set_something with output_finder --- makefile | 2 +- scripts/genie.lua | 3 +- src/emu/output.h | 7 +++ src/mame/drivers/4004clk.cpp | 49 +++++++-------- src/mame/drivers/acrnsys1.cpp | 24 ++++++-- src/mame/drivers/alesis.cpp | 11 +++- src/mame/drivers/atari400.cpp | 8 +-- src/mame/drivers/bartop52.cpp | 12 ++-- src/mame/drivers/bfm_sc4.cpp | 65 +++++++++----------- src/mame/drivers/cmi.cpp | 31 ++++------ src/mame/drivers/dlair.cpp | 68 ++++++++++---------- src/mame/drivers/ecoinf3.cpp | 130 +++++++++++++++++++-------------------- src/mame/drivers/elekscmp.cpp | 40 ++++++------ src/mame/drivers/junior.cpp | 46 ++++++++------ src/mame/drivers/maxaflex.cpp | 65 ++++++++++++-------- src/mame/drivers/mpu3.cpp | 65 ++++++++++---------- src/mame/drivers/sitcom.cpp | 28 ++++++--- src/mame/drivers/tk80.cpp | 83 +++++++++++++++---------- src/mame/drivers/wacky_gator.cpp | 108 +++++++++++++++++--------------- src/mame/includes/alesis.h | 43 +++++++------ src/mame/includes/atari400.h | 12 ++-- src/mame/includes/bfm_sc4.h | 39 +++++++----- src/mame/includes/sms.h | 16 +++-- src/mame/layout/acrnsys1.lay | 18 +++--- src/mame/machine/esqlcd.cpp | 100 ++++++++++-------------------- src/mame/machine/esqlcd.h | 7 ++- src/mame/machine/esqvfd.cpp | 20 +++--- src/mame/machine/esqvfd.h | 4 +- src/mame/machine/model2.cpp | 91 +++++++++++++-------------- src/mame/machine/sms.cpp | 4 +- 30 files changed, 629 insertions(+), 570 deletions(-) diff --git a/makefile b/makefile index 657f4d9a404..8e46e9133f2 100644 --- a/makefile +++ b/makefile @@ -83,7 +83,7 @@ # OVERRIDE_CXX = c++ # OVERRIDE_LD = ld -# DEPRECATED = 1 +# DEPRECATED = 0 # LTO = 1 # SSE2 = 1 # OPENMP = 1 diff --git a/scripts/genie.lua b/scripts/genie.lua index 6d89686fce8..ad7018ed5c8 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -763,7 +763,7 @@ if (_OPTIONS["SHADOW_CHECK"]=="1") then end -- only show deprecation warnings when enabled -if _OPTIONS["DEPRECATED"]~="1" then +if _OPTIONS["DEPRECATED"]=="0" then buildoptions { "-Wno-deprecated-declarations" } @@ -933,6 +933,7 @@ end "-Wwrite-strings", "-Wno-sign-compare", "-Wno-conversion", + "-Wno-error=deprecated-declarations", } -- warnings only applicable to C compiles buildoptions_c { diff --git a/src/emu/output.h b/src/emu/output.h index ef5080b327f..dcdf66bc73d 100644 --- a/src/emu/output.h +++ b/src/emu/output.h @@ -103,6 +103,13 @@ public: auto &operator[](unsigned n) { return m_proxies[n]; } auto &operator[](unsigned n) const { return m_proxies[n]; } + auto begin() { return std::begin(m_proxies); } + auto end() { return std::begin(m_proxies); } + auto begin() const { return std::begin(m_proxies); } + auto end() const { return std::begin(m_proxies); } + auto cbegin() const { return std::begin(m_proxies); } + auto cend() const { return std::begin(m_proxies); } + void resolve() { resolve<0U>(m_proxies); } private: diff --git a/src/mame/drivers/4004clk.cpp b/src/mame/drivers/4004clk.cpp index 45d4fd4b217..d187741c3d2 100644 --- a/src/mame/drivers/4004clk.cpp +++ b/src/mame/drivers/4004clk.cpp @@ -21,18 +21,24 @@ class nixieclock_state : public driver_device { public: - nixieclock_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) { } + nixieclock_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_nixie_out(*this, "nixie%u", 0U) + , m_neon_out(*this, "neon%u", 0U) + { } + void _4004clk(machine_config &config); + +protected: DECLARE_WRITE8_MEMBER( nixie_w ); DECLARE_WRITE8_MEMBER( neon_w ); - void _4004clk(machine_config &config); void _4004clk_mem(address_map &map); void _4004clk_mp(address_map &map); void _4004clk_rom(address_map &map); void _4004clk_rp(address_map &map); void _4004clk_stat(address_map &map); -protected: + virtual void machine_start() override; private: @@ -52,36 +58,28 @@ private: 10; } - void output_set_nixie_value(int index, int value) - { - output().set_indexed_value("nixie", index, value); - } - - void output_set_neon_value(int index, int value) - { - output().set_indexed_value("neon", index, value); - } - uint16_t m_nixie[16]; + output_finder<6> m_nixie_out; + output_finder<4> m_neon_out; }; WRITE8_MEMBER(nixieclock_state::nixie_w) { m_nixie[offset >> 4] = data; - output_set_nixie_value(5, nixie_to_num(((m_nixie[2] & 3)<<8) | (m_nixie[1] << 4) | m_nixie[0])); - output_set_nixie_value(4, nixie_to_num((m_nixie[4] << 6) | (m_nixie[3] << 2) | (m_nixie[2] >>2))); - output_set_nixie_value(3, nixie_to_num(((m_nixie[7] & 3)<<8) | (m_nixie[6] << 4) | m_nixie[5])); - output_set_nixie_value(2, nixie_to_num((m_nixie[9] << 6) | (m_nixie[8] << 2) | (m_nixie[7] >>2))); - output_set_nixie_value(1, nixie_to_num(((m_nixie[12] & 3)<<8) | (m_nixie[11] << 4) | m_nixie[10])); - output_set_nixie_value(0, nixie_to_num((m_nixie[14] << 6) | (m_nixie[13] << 2) | (m_nixie[12] >>2))); + m_nixie_out[5] = nixie_to_num(((m_nixie[2] & 3)<<8) | (m_nixie[1] << 4) | m_nixie[0]); + m_nixie_out[4] = nixie_to_num((m_nixie[4] << 6) | (m_nixie[3] << 2) | (m_nixie[2] >>2)); + m_nixie_out[3] = nixie_to_num(((m_nixie[7] & 3)<<8) | (m_nixie[6] << 4) | m_nixie[5]); + m_nixie_out[2] = nixie_to_num((m_nixie[9] << 6) | (m_nixie[8] << 2) | (m_nixie[7] >>2)); + m_nixie_out[1] = nixie_to_num(((m_nixie[12] & 3)<<8) | (m_nixie[11] << 4) | m_nixie[10]); + m_nixie_out[0] = nixie_to_num((m_nixie[14] << 6) | (m_nixie[13] << 2) | (m_nixie[12] >>2)); } WRITE8_MEMBER(nixieclock_state::neon_w) { - output_set_neon_value(0, BIT(data,3)); - output_set_neon_value(1, BIT(data,2)); - output_set_neon_value(2, BIT(data,1)); - output_set_neon_value(3, BIT(data,0)); + m_neon_out[0] = BIT(data,3); + m_neon_out[1] = BIT(data,2); + m_neon_out[2] = BIT(data,1); + m_neon_out[3] = BIT(data,0); } ADDRESS_MAP_START(nixieclock_state::_4004clk_rom) @@ -125,6 +123,9 @@ INPUT_PORTS_END void nixieclock_state::machine_start() { + m_nixie_out.resolve(); + m_neon_out.resolve(); + /* register for state saving */ save_pointer(NAME(m_nixie), 6); } @@ -132,7 +133,7 @@ void nixieclock_state::machine_start() MACHINE_CONFIG_START(nixieclock_state::_4004clk) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", I4004, XTAL(5'000'000) / 8) + MCFG_CPU_ADD("maincpu", I4004, 5_MHz_XTAL / 8); MCFG_I4004_ROM_MAP(_4004clk_rom) MCFG_I4004_RAM_MEMORY_MAP(_4004clk_mem) MCFG_I4004_ROM_PORTS_MAP(_4004clk_rp) diff --git a/src/mame/drivers/acrnsys1.cpp b/src/mame/drivers/acrnsys1.cpp index 62623ef4900..b5fe96b04f5 100644 --- a/src/mame/drivers/acrnsys1.cpp +++ b/src/mame/drivers/acrnsys1.cpp @@ -66,12 +66,14 @@ public: m_maincpu(*this, "maincpu"), m_ttl74145(*this, "ic8_7445"), m_cass(*this, "cassette"), + m_display(*this, "digit%u", 0U), m_digit(0) { } void acrnsys1(machine_config &config); protected: + virtual void machine_start() override; DECLARE_READ8_MEMBER(ins8154_b1_port_a_r); DECLARE_WRITE8_MEMBER(ins8154_b1_port_a_w); DECLARE_WRITE8_MEMBER(acrnsys1_led_segment_w); @@ -83,6 +85,7 @@ private: required_device m_maincpu; required_device m_ttl74145; required_device m_cass; + output_finder<9> m_display; uint8_t m_digit; uint8_t m_cass_data[4]; bool m_cass_state; @@ -91,6 +94,17 @@ private: +void acrnsys1_state::machine_start() +{ + m_display.resolve(); + + save_item(NAME(m_digit)); + save_item(NAME(m_cass_data)); + save_item(NAME(m_cass_state)); + save_item(NAME(m_cassold)); +} + + /*************************************************************************** KEYBOARD HANDLING ***************************************************************************/ @@ -157,9 +171,11 @@ TIMER_DEVICE_CALLBACK_MEMBER(acrnsys1_state::acrnsys1_p) WRITE8_MEMBER( acrnsys1_state::acrnsys1_led_segment_w ) { - uint8_t key_line = m_ttl74145->read(); + uint16_t const key_line = m_ttl74145->read(); - output().set_digit_value(key_line, data); + for (unsigned i = 0U; 9U > i; ++i) + if (BIT(key_line, i)) + m_display[i] = data; } @@ -286,5 +302,5 @@ ROM_END GAME DRIVERS ***************************************************************************/ -/* YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS */ -COMP( 1978, acrnsys1, 0, 0, acrnsys1, acrnsys1, acrnsys1_state, 0, "Acorn", "Acorn System 1", 0 ) +// YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS +COMP( 1978, acrnsys1, 0, 0, acrnsys1, acrnsys1, acrnsys1_state, 0, "Acorn", "Acorn System 1", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/alesis.cpp b/src/mame/drivers/alesis.cpp index 0b37917059a..515ad47d800 100644 --- a/src/mame/drivers/alesis.cpp +++ b/src/mame/drivers/alesis.cpp @@ -96,7 +96,7 @@ READ8_MEMBER( alesis_state::mmt8_led_r ) WRITE8_MEMBER( alesis_state::track_led_w ) { for (int i=0; i<8; i++) - output().set_indexed_value("track_led", i + 1, BIT(data, i)); + m_track_led[i] = BIT(data, i); } READ8_MEMBER( alesis_state::mmt8_p3_r ) @@ -330,6 +330,11 @@ PALETTE_INIT_MEMBER(alesis_state, alesis) palette.set_pen_color(1, rgb_t(92, 83, 88)); } +void alesis_state::machine_start() +{ + m_track_led.resolve(); +} + void alesis_state::machine_reset() { m_kb_matrix = 0xff; @@ -348,7 +353,7 @@ HD44780_PIXEL_UPDATE(alesis_state::sr16_pixel_update) MACHINE_CONFIG_START(alesis_state::hr16) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu",I8031, XTAL(12'000'000)) + MCFG_CPU_ADD("maincpu",I8031, 12_MHz_XTAL) MCFG_CPU_PROGRAM_MAP(hr16_mem) MCFG_CPU_IO_MAP(hr16_io) MCFG_MCS51_PORT_P1_IN_CB(IOPORT("SELECT")) @@ -376,7 +381,7 @@ MACHINE_CONFIG_START(alesis_state::hr16) MCFG_HD44780_LCD_SIZE(2, 16) /* sound hardware */ - MCFG_ALESIS_DM3AG_ADD("dm3ag", XTAL(12'000'000)/2) + MCFG_ALESIS_DM3AG_ADD("dm3ag", 12_MHz_XTAL/2) MCFG_NVRAM_ADD_0FILL("nvram") MACHINE_CONFIG_END diff --git a/src/mame/drivers/atari400.cpp b/src/mame/drivers/atari400.cpp index 717917d8f7a..fd58c220450 100644 --- a/src/mame/drivers/atari400.cpp +++ b/src/mame/drivers/atari400.cpp @@ -2137,8 +2137,8 @@ MACHINE_CONFIG_START(a400_state::atari_common_nodac) MCFG_POKEY_POT7_R_CB(IOPORT("analog_7")) MCFG_POKEY_SERIN_R_CB(DEVREAD8("fdc", atari_fdc_device, serin_r)) MCFG_POKEY_SEROUT_W_CB(DEVWRITE8("fdc", atari_fdc_device, serout_w)) - MCFG_POKEY_KEYBOARD_CB(atari_common_state, a800_keyboard) - MCFG_POKEY_INTERRUPT_CB(atari_common_state, interrupt_cb) + MCFG_POKEY_KEYBOARD_CB(a400_state, a800_keyboard) + MCFG_POKEY_INTERRUPT_CB(a400_state, interrupt_cb) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 1.0) MACHINE_CONFIG_END @@ -2350,8 +2350,8 @@ MACHINE_CONFIG_START(a400_state::a5200) MCFG_SOUND_MODIFY("pokey") MCFG_POKEY_SERIN_R_CB(NOOP) MCFG_POKEY_SEROUT_W_CB(NOOP) - MCFG_POKEY_KEYBOARD_CB(atari_common_state, a5200_keypads) - MCFG_POKEY_INTERRUPT_CB(atari_common_state, interrupt_cb) + MCFG_POKEY_KEYBOARD_CB(a400_state, a5200_keypads) + MCFG_POKEY_INTERRUPT_CB(a400_state, interrupt_cb) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 1.0) diff --git a/src/mame/drivers/bartop52.cpp b/src/mame/drivers/bartop52.cpp index 0a05694af39..b24c40fc455 100644 --- a/src/mame/drivers/bartop52.cpp +++ b/src/mame/drivers/bartop52.cpp @@ -37,10 +37,12 @@ public: : atari_common_state(mconfig, type, tag) { } + void a5200(machine_config &config); + +protected: TIMER_DEVICE_CALLBACK_MEMBER( bartop_interrupt ); virtual void machine_reset() override; - void a5200(machine_config &config); void a5200_mem(address_map &map); }; @@ -113,6 +115,8 @@ INPUT_PORTS_END void bartop52_state::machine_reset() { + atari_common_state::machine_reset(); + pokey_device *pokey = machine().device("pokey"); pokey->write(15,0); } @@ -143,7 +147,7 @@ MACHINE_CONFIG_START(bartop52_state::a5200) MCFG_SCREEN_PALETTE("palette") MCFG_PALETTE_ADD("palette", 256) - MCFG_PALETTE_INIT_OWNER(atari_common_state, atari) + MCFG_PALETTE_INIT_OWNER(bartop52_state, atari) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") @@ -153,8 +157,8 @@ MACHINE_CONFIG_START(bartop52_state::a5200) MCFG_POKEY_POT1_R_CB(IOPORT("analog_1")) MCFG_POKEY_POT2_R_CB(IOPORT("analog_2")) MCFG_POKEY_POT3_R_CB(IOPORT("analog_3")) - MCFG_POKEY_KEYBOARD_CB(atari_common_state, a5200_keypads) - MCFG_POKEY_INTERRUPT_CB(atari_common_state, interrupt_cb) + MCFG_POKEY_KEYBOARD_CB(bartop52_state, a5200_keypads) + MCFG_POKEY_INTERRUPT_CB(bartop52_state, interrupt_cb) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) diff --git a/src/mame/drivers/bfm_sc4.cpp b/src/mame/drivers/bfm_sc4.cpp index 5b5e27fab51..0cb777215bd 100644 --- a/src/mame/drivers/bfm_sc4.cpp +++ b/src/mame/drivers/bfm_sc4.cpp @@ -445,28 +445,28 @@ READ16_MEMBER(sc4_state::sc4_mem_r) return 0x0000; } -WRITE8_MEMBER(bfm_sc45_state::mux_output_w) +void bfm_sc45_state::machine_start() { - int i; - int off = offset<<3; - - for (i=0; i<8; i++) - output().set_lamp_value(off+i, ((data & (1 << i)) != 0)); + m_lamps.resolve(); + m_matrix.resolve(); + m_digits.resolve(); +} +WRITE8_MEMBER(bfm_sc45_state::mux_output_w) +{ + int const off = offset<<3; - output().set_indexed_value("matrix", off+i, ((data & (1 << i)) != 0)); + for (int i=0; i<8; i++) + m_lamps[off+i] = BIT(data, i); } WRITE8_MEMBER(bfm_sc45_state::mux_output2_w) { - int i; - int off = offset<<3; + int const off = offset<<3; // some games use this as a matrix port (luckb etc.) - for (i=0; i<8; i++) - { - output().set_indexed_value("matrix", off+i, ((data & (1 << i)) != 0)); - } + for (int i=0; i<8; i++) + m_matrix[off+i] = BIT(data, i); // others drive 7-segs with it.. so rendering it there as well in our debug layouts @@ -474,28 +474,24 @@ WRITE8_MEMBER(bfm_sc45_state::mux_output2_w) { m_segment_34_cache[offset] = data; - uint16_t short_data; - uint8_t byte_data_first_segment; - uint8_t byte_data_second_segment; for (int digit = 0; digit < 32; digit += 2) { - short_data = (m_segment_34_cache[digit + 1] << 8) | m_segment_34_cache[digit]; - byte_data_first_segment = (short_data >> 1) & 15; - byte_data_second_segment = (short_data >> 6) & 15; - output().set_digit_value(digit, SEGMENT_34_ENCODING_LOOKUP[byte_data_first_segment]); - output().set_digit_value(digit + 1, SEGMENT_34_ENCODING_LOOKUP[byte_data_second_segment]); + uint16_t const short_data = (m_segment_34_cache[digit + 1] << 8) | m_segment_34_cache[digit]; + uint8_t byte_data_first_segment = (short_data >> 1) & 15; + uint8_t const byte_data_second_segment = (short_data >> 6) & 15; + m_digits[digit] = SEGMENT_34_ENCODING_LOOKUP[byte_data_first_segment]; + m_digits[digit + 1] = SEGMENT_34_ENCODING_LOOKUP[byte_data_second_segment]; if (digit == 0 || digit == 2) { byte_data_first_segment = (short_data >> 11) & 15; - output().set_digit_value((digit / 2) + 32, SEGMENT_34_ENCODING_LOOKUP[byte_data_first_segment]); + m_digits[(digit / 2) + 32] = SEGMENT_34_ENCODING_LOOKUP[byte_data_first_segment]; } } } else { - uint8_t bf7segdata = bitswap<8>(data,0,7,6,5,4,3,2,1); - output().set_digit_value(offset, bf7segdata); + m_digits[offset] = bitswap<8>(data,0,7,6,5,4,3,2,1); } } @@ -805,16 +801,20 @@ uint16_t sc4_state::bfm_sc4_68307_portb_r(address_space &space, bool dedicated, } } -MACHINE_RESET_MEMBER(sc4_state,sc4) +void sc4_state::machine_reset() { + bfm_sc45_state::machine_reset(); + m_dochk41 = true; sec.reset(); } -MACHINE_START_MEMBER(sc4_state,sc4) +void sc4_state::machine_start() { + bfm_sc45_state::machine_start(); + m_nvram->set_base(m_mainram, sizeof(m_mainram)); m_maincpu->set_port_callbacks( @@ -897,9 +897,6 @@ MACHINE_CONFIG_START(sc4_state::sc4_common) MCFG_MC68307_SERIAL_INPORT_CALLBACK(READ8(sc4_state, m68307_duart_input_r)) MCFG_MC68307_SERIAL_OUTPORT_CALLBACK(WRITE8(sc4_state, m68307_duart_output_w)) - MCFG_MACHINE_START_OVERRIDE(sc4_state, sc4 ) - MCFG_MACHINE_RESET_OVERRIDE(sc4_state, sc4 ) - /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") @@ -1245,11 +1242,11 @@ MACHINE_CONFIG_START(sc4_state::sc4_no_reels) sc4_common(config); MACHINE_CONFIG_END -MACHINE_START_MEMBER(sc4_adder4_state,adder4) +void sc4_adder4_state::machine_start() { - m_adder4cpuregion = (uint32_t*)memregion( "adder4" )->base(); + sc4_state::machine_start(); + m_adder4ram = make_unique_clear(0x10000); - MACHINE_START_CALL_MEMBER(sc4); } MACHINE_CONFIG_START(sc4_adder4_state::sc4_adder4) @@ -1257,8 +1254,6 @@ MACHINE_CONFIG_START(sc4_adder4_state::sc4_adder4) MCFG_CPU_ADD("adder4", M68340, 25175000) // 68340 (CPU32 core) MCFG_CPU_PROGRAM_MAP(sc4_adder4_map) - - MCFG_MACHINE_START_OVERRIDE(sc4_adder4_state, adder4 ) MACHINE_CONFIG_END MACHINE_CONFIG_START(sc4_state::sc4dmd) @@ -1269,8 +1264,6 @@ MACHINE_CONFIG_START(sc4_state::sc4dmd) MCFG_DEVICE_ADD("dm01", BFM_DM01, 0) MCFG_BFM_DM01_BUSY_CB(WRITELINE(sc4_state, bfmdm01_busy)) - MCFG_MACHINE_START_OVERRIDE(sc4_state, sc4 ) - MCFG_STARPOINT_RM20_48STEP_ADD("reel1") MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(sc4_state, reel1_optic_cb)) MCFG_STARPOINT_RM20_48STEP_ADD("reel2") diff --git a/src/mame/drivers/cmi.cpp b/src/mame/drivers/cmi.cpp index 9e5a27c1ffb..424e910cdf6 100644 --- a/src/mame/drivers/cmi.cpp +++ b/src/mame/drivers/cmi.cpp @@ -447,6 +447,7 @@ public: , m_keypad_a_port(*this, "KEYPAD_A") , m_keypad_b_port(*this, "KEYPAD_B") , m_key_mux_ports{ { *this, "KEY_%u_0", 0 }, { *this, "KEY_%u_1", 0 }, { *this, "KEY_%u_2", 0 }, { *this, "KEY_%u_3", 0 } } + , m_digit(*this, "digit%u", 0U) , m_cmi07_ram(*this, "cmi07_ram") { } @@ -547,9 +548,7 @@ public: DECLARE_WRITE_LINE_MEMBER( cmi10_u20_cb2_w ); DECLARE_WRITE_LINE_MEMBER( cmi10_u21_cb2_w ); DECLARE_READ8_MEMBER( cmi10_u21_a_r ); - DECLARE_WRITE16_MEMBER( cmi_iix_update_dp1 ); - DECLARE_WRITE16_MEMBER( cmi_iix_update_dp2 ); - DECLARE_WRITE16_MEMBER( cmi_iix_update_dp3 ); + template DECLARE_WRITE16_MEMBER( cmi_iix_update_dp ); DECLARE_WRITE_LINE_MEMBER( msm5832_irq ); DECLARE_WRITE_LINE_MEMBER( mkbd_kbd_acia_int ); @@ -564,8 +563,8 @@ public: void maincpu2_map(address_map &map); void midicpu_map(address_map &map); void muskeys_map(address_map &map); -protected: +protected: required_device m_maincpu1; required_device m_maincpu2; required_device m_muskeyscpu; @@ -626,6 +625,8 @@ protected: required_ioport_array<3> m_key_mux_ports[4]; + output_finder<12> m_digit; + required_shared_ptr m_cmi07_ram; address_space *m_cpu1space; @@ -2506,19 +2507,9 @@ WRITE_LINE_MEMBER( cmi_state::cmi10_u20_cb2_w ) m_dp3->wr_w(state); } -WRITE16_MEMBER( cmi_state::cmi_iix_update_dp1 ) -{ - output().set_digit_value(0 + (offset ^ 3), data); -} - -WRITE16_MEMBER( cmi_state::cmi_iix_update_dp2 ) +template WRITE16_MEMBER( cmi_state::cmi_iix_update_dp ) { - output().set_digit_value(4 + (offset ^ 3), data); -} - -WRITE16_MEMBER( cmi_state::cmi_iix_update_dp3 ) -{ - output().set_digit_value(8 + (offset ^ 3), data); + m_digit[(N << 2) | ((offset ^ 3) & 3)] = data; } /* Begin Conversion */ @@ -2700,6 +2691,8 @@ void cmi_state::machine_reset() void cmi_state::machine_start() { + m_digit.resolve(); + m_q133_rom = (uint8_t *)m_q133_region->base(); // allocate timers for the built-in two channel timer @@ -2776,11 +2769,11 @@ MACHINE_CONFIG_START(cmi_state::cmi2x) /* alpha-numeric display */ MCFG_DEVICE_ADD("dp1", DL1416T, 0) - MCFG_DL1416_UPDATE_HANDLER(WRITE16(cmi_state, cmi_iix_update_dp1)) + MCFG_DL1416_UPDATE_HANDLER(WRITE16(cmi_state, cmi_iix_update_dp<0>)) MCFG_DEVICE_ADD("dp2", DL1416T, 0) - MCFG_DL1416_UPDATE_HANDLER(WRITE16(cmi_state, cmi_iix_update_dp2)) + MCFG_DL1416_UPDATE_HANDLER(WRITE16(cmi_state, cmi_iix_update_dp<1>)) MCFG_DEVICE_ADD("dp3", DL1416T, 0) - MCFG_DL1416_UPDATE_HANDLER(WRITE16(cmi_state, cmi_iix_update_dp3)) + MCFG_DL1416_UPDATE_HANDLER(WRITE16(cmi_state, cmi_iix_update_dp<2>)) /* video hardware */ MCFG_SCREEN_ADD_MONOCHROME("screen", RASTER, rgb_t::green()) diff --git a/src/mame/drivers/dlair.cpp b/src/mame/drivers/dlair.cpp index fa234128fd2..739739cf65d 100644 --- a/src/mame/drivers/dlair.cpp +++ b/src/mame/drivers/dlair.cpp @@ -63,19 +63,22 @@ public: m_ldv1000(*this, "ld_ldv1000"), m_pr7820(*this, "ld_pr7820"), m_22vp932(*this, "ld_22vp932"), - m_videoram(*this, "videoram") + m_videoram(*this, "videoram"), + m_digits(*this, "digit%u", 0U) { } - required_device m_maincpu; - optional_device m_speaker; - optional_device m_gfxdecode; - optional_device m_palette; - optional_device m_ldv1000; - optional_device m_pr7820; - optional_device m_22vp932; - optional_shared_ptr m_videoram; + DECLARE_CUSTOM_INPUT_MEMBER(laserdisc_status_r); + DECLARE_CUSTOM_INPUT_MEMBER(laserdisc_command_r); + DECLARE_DRIVER_INIT(fixed); + DECLARE_DRIVER_INIT(variable); + + void dlair_base(machine_config &config); + void dlair_pr7820(machine_config &config); + void dleuro(machine_config &config); + void dlair_ldv1000(machine_config &config); +protected: void laserdisc_data_w(uint8_t data) { if (m_ldv1000 != nullptr) m_ldv1000->data_w(data); @@ -115,30 +118,35 @@ public: return CLEAR_LINE; } - uint8_t m_last_misc; - uint8_t m_laserdisc_data; DECLARE_WRITE8_MEMBER(misc_w); DECLARE_WRITE8_MEMBER(dleuro_misc_w); DECLARE_WRITE8_MEMBER(led_den1_w); DECLARE_WRITE8_MEMBER(led_den2_w); DECLARE_READ8_MEMBER(laserdisc_r); DECLARE_WRITE8_MEMBER(laserdisc_w); - DECLARE_CUSTOM_INPUT_MEMBER(laserdisc_status_r); - DECLARE_CUSTOM_INPUT_MEMBER(laserdisc_command_r); - DECLARE_DRIVER_INIT(fixed); - DECLARE_DRIVER_INIT(variable); - DECLARE_MACHINE_START(dlair); - DECLARE_MACHINE_RESET(dlair); + virtual void machine_start() override; + virtual void machine_reset() override; DECLARE_PALETTE_INIT(dleuro); uint32_t screen_update_dleuro(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); DECLARE_WRITE_LINE_MEMBER(write_speaker); - void dlair_base(machine_config &config); - void dlair_pr7820(machine_config &config); - void dleuro(machine_config &config); - void dlair_ldv1000(machine_config &config); + void dleuro_io_map(address_map &map); void dleuro_map(address_map &map); void dlus_map(address_map &map); + +private: + required_device m_maincpu; + optional_device m_speaker; + optional_device m_gfxdecode; + optional_device m_palette; + optional_device m_ldv1000; + optional_device m_pr7820; + optional_device m_22vp932; + optional_shared_ptr m_videoram; + output_finder<16> m_digits; + + uint8_t m_last_misc; + uint8_t m_laserdisc_data; }; @@ -239,12 +247,16 @@ uint32_t dlair_state::screen_update_dleuro(screen_device &screen, bitmap_ind16 & * *************************************/ -MACHINE_START_MEMBER(dlair_state,dlair) +void dlair_state::machine_start() { + m_digits.resolve(); + + save_item(NAME(m_last_misc)); + save_item(NAME(m_laserdisc_data)); } -MACHINE_RESET_MEMBER(dlair_state,dlair) +void dlair_state::machine_reset() { #if 0 @@ -317,13 +329,13 @@ WRITE8_MEMBER(dlair_state::dleuro_misc_w) WRITE8_MEMBER(dlair_state::led_den1_w) { - output().set_digit_value(0 + (offset & 7), led_map[data & 0x0f]); + m_digits[0 | (offset & 7)] = led_map[data & 0x0f]; } WRITE8_MEMBER(dlair_state::led_den2_w) { - output().set_digit_value(8 + (offset & 7), led_map[data & 0x0f]); + m_digits[8 | (offset & 7)] = led_map[data & 0x0f]; } @@ -721,9 +733,6 @@ MACHINE_CONFIG_START(dlair_state::dlair_base) MCFG_CPU_PROGRAM_MAP(dlus_map) MCFG_CPU_PERIODIC_INT_DRIVER(dlair_state, irq0_line_hold, (double)MASTER_CLOCK_US/8/16/16/16/16) - MCFG_MACHINE_START_OVERRIDE(dlair_state,dlair) - MCFG_MACHINE_RESET_OVERRIDE(dlair_state,dlair) - /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") @@ -771,9 +780,6 @@ MACHINE_CONFIG_START(dlair_state::dleuro) MCFG_WATCHDOG_ADD("watchdog") MCFG_WATCHDOG_TIME_INIT(attotime::from_hz(MASTER_CLOCK_EURO/(16*16*16*16*16*8))) - MCFG_MACHINE_START_OVERRIDE(dlair_state,dlair) - MCFG_MACHINE_RESET_OVERRIDE(dlair_state,dlair) - MCFG_LASERDISC_22VP932_ADD("ld_22vp932") MCFG_LASERDISC_OVERLAY_DRIVER(256, 256, dlair_state, screen_update_dleuro) MCFG_LASERDISC_OVERLAY_PALETTE("palette") diff --git a/src/mame/drivers/ecoinf3.cpp b/src/mame/drivers/ecoinf3.cpp index 90b969d2c67..ac88dea594b 100644 --- a/src/mame/drivers/ecoinf3.cpp +++ b/src/mame/drivers/ecoinf3.cpp @@ -23,42 +23,40 @@ #include "ecoinf3.lh" +#include + class ecoinf3_state : public driver_device { public: - ecoinf3_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + ecoinf3_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), - m_reel0(*this, "reel0"), - m_reel1(*this, "reel1"), - m_reel2(*this, "reel2"), - m_reel3(*this, "reel3") + m_reels(*this, "reel%u", 0U), + m_lamp_outputs(*this, "lamp%u", 0U), + m_vfd_outputs(*this, "vfd%u", 0U) { - strobe_amount = 0; - strobe_addr = 0; - m_percent_mux = 0; } - required_device m_maincpu; - required_device m_reel0; - required_device m_reel1; - required_device m_reel2; - required_device m_reel3; - - uint16_t m_lamps[16]; - uint16_t m_chars[14]; - void update_display(); + DECLARE_DRIVER_INIT(ecoinf3); + DECLARE_DRIVER_INIT(ecoinf3_swap); + void ecoinf3_pyramid(machine_config &config); - int strobe_addr; - int strobe_amount; - int m_optic_pattern; - DECLARE_WRITE_LINE_MEMBER(reel0_optic_cb) { if (state) m_optic_pattern |= 0x01; else m_optic_pattern &= ~0x01; } - DECLARE_WRITE_LINE_MEMBER(reel1_optic_cb) { if (state) m_optic_pattern |= 0x02; else m_optic_pattern &= ~0x02; } - DECLARE_WRITE_LINE_MEMBER(reel2_optic_cb) { if (state) m_optic_pattern |= 0x04; else m_optic_pattern &= ~0x04; } - DECLARE_WRITE_LINE_MEMBER(reel3_optic_cb) { if (state) m_optic_pattern |= 0x08; else m_optic_pattern &= ~0x08; } +protected: + virtual void machine_start() override + { + m_lamp_outputs.resolve(); + m_vfd_outputs.resolve(); + + save_item(NAME(m_lamps)); + save_item(NAME(m_chars)); + save_item(NAME(m_strobe_addr)); + save_item(NAME(m_strobe_amount)); + save_item(NAME(m_optic_pattern)); + save_item(NAME(m_percent_mux)); + } - int m_percent_mux; + template DECLARE_WRITE_LINE_MEMBER(reel_optic_cb) { if (state) m_optic_pattern |= (1 << N); else m_optic_pattern &= ~(1 << N); } DECLARE_READ8_MEMBER(ppi8255_intf_a_read_a) { int ret = 0x00; logerror("%04x - ppi8255_intf_a_read_a %02x\n", m_maincpu->pcbase(), ret); return ret; } DECLARE_READ8_MEMBER(ppi8255_intf_a_read_b) @@ -170,16 +168,12 @@ public: } DECLARE_READ8_MEMBER(ppi8255_intf_h_read_c) { int ret = 0x00; logerror("%04x - ppi8255_intf_h_read_c %02x\n", m_maincpu->pcbase(), ret); return ret; } - void update_lamps(void) + void update_lamps() { for (int i=0; i<16; i++) { - for (int bit=0;bit<16;bit++) - { - int data = ((m_lamps[i] << bit)&0x8000)>>15; - - output().set_indexed_value("lamp", (i*16)+bit, data ); - } + for (int bit=0; bit<16; bit++) + m_lamp_outputs[(i << 4) | bit] = BIT(m_lamps[i], 15 - bit); } } @@ -187,20 +181,20 @@ public: DECLARE_WRITE8_MEMBER(ppi8255_intf_a_write_a_strobedat0) { // logerror("%04x - ppi8255_intf_a_(used)write_a %02x (STROBEDAT?)\n", m_maincpu->pcbase(), data); - if (strobe_amount) + if (m_strobe_amount) { - m_lamps[strobe_addr] = (m_lamps[strobe_addr] &0xff00) | (data & 0x00ff); - strobe_amount--; + m_lamps[m_strobe_addr] = (m_lamps[m_strobe_addr] & 0xff00) | (data & 0x00ff); + m_strobe_amount--; } } DECLARE_WRITE8_MEMBER(ppi8255_intf_a_write_b_strobedat1) { // logerror("%04x - ppi8255_intf_a_(used)write_b %02x (STROBEDAT?)\n", m_maincpu->pcbase(), data); - if (strobe_amount) + if (m_strobe_amount) { - m_lamps[strobe_addr] = (m_lamps[strobe_addr] &0x00ff) | (data << 8); - strobe_amount--; + m_lamps[m_strobe_addr] = (m_lamps[m_strobe_addr] & 0x00ff) | (data << 8); + m_strobe_amount--; } } DECLARE_WRITE8_MEMBER(ppi8255_intf_a_write_c_strobe) @@ -208,11 +202,11 @@ public: if (data>=0xf0) { // logerror("%04x - ppi8255_intf_a_(used)write_c %02x (STROBE?)\n", m_maincpu->pcbase(), data); - strobe_addr = data & 0xf; + m_strobe_addr = data & 0xf; // hack, it writes values for the lamps, then writes 0x00 afterwards, probably giving the bulbs power, then removing the power // before switching the strobe to the next line? - strobe_amount = 2; + m_strobe_amount = 2; update_lamps(); } @@ -230,22 +224,22 @@ public: DECLARE_WRITE8_MEMBER(ppi8255_intf_d_write_a_reel01) { // logerror("%04x - ppi8255_intf_d_(used)write_a %02x\n", m_maincpu->pcbase(), data); - m_reel0->update( data &0x0f); - m_reel1->update((data>>4)&0x0f); + m_reels[0]->update( data &0x0f); + m_reels[1]->update((data>>4)&0x0f); - awp_draw_reel(machine(),"reel1", *m_reel0); - awp_draw_reel(machine(),"reel2", *m_reel1); + awp_draw_reel(machine(),"reel1", *m_reels[0]); + awp_draw_reel(machine(),"reel2", *m_reels[1]); } DECLARE_WRITE8_MEMBER(ppi8255_intf_d_write_b_reel23) { // logerror("%04x - ppi8255_intf_d_(used)write_b %02x\n", m_maincpu->pcbase(), data); - m_reel2->update( data &0x0f); - m_reel3->update((data>>4)&0x0f); + m_reels[2]->update( data &0x0f); + m_reels[3]->update((data>>4)&0x0f); - awp_draw_reel(machine(),"reel3", *m_reel2); - awp_draw_reel(machine(),"reel4", *m_reel3); + awp_draw_reel(machine(),"reel3", *m_reels[2]); + awp_draw_reel(machine(),"reel4", *m_reels[3]); } DECLARE_WRITE8_MEMBER(ppi8255_intf_d_write_c) { logerror("%04x - ppi8255_intf_d_(used)write_c %02x\n", m_maincpu->pcbase(), data);} @@ -271,12 +265,23 @@ public: DECLARE_WRITE8_MEMBER(ppi8255_intf_h_write_b) { logerror("%04x - ppi8255_intf_h_(used)write_b %02x\n", m_maincpu->pcbase(), data); } DECLARE_WRITE8_MEMBER(ppi8255_intf_h_write_c) { logerror("%04x - ppi8255_intf_h_(used)write_c %02x\n", m_maincpu->pcbase(), data); } - - DECLARE_DRIVER_INIT(ecoinf3); - DECLARE_DRIVER_INIT(ecoinf3_swap); - void ecoinf3_pyramid(machine_config &config); void pyramid_memmap(address_map &map); void pyramid_portmap(address_map &map); + +private: + required_device m_maincpu; + required_device_array m_reels; + output_finder<16 * 16> m_lamp_outputs; + output_finder<14> m_vfd_outputs; + + uint16_t m_lamps[16]; + uint16_t m_chars[14]; + + int m_strobe_addr = 0; + int m_strobe_amount = 0; + int m_optic_pattern = 0; + + int m_percent_mux = 0; }; @@ -357,14 +362,6 @@ static uint32_t set_display(uint32_t segin) return bitswap<32>(segin, 31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,11,9,15,13,12,8,10,14,7,6,5,4,3,2,1,0); } -void ecoinf3_state::update_display() -{ - for (int i =0; i<14; i++) - { - output().set_indexed_value("vfd", i, set_display(m_chars[i]) ); - } -} - // is the 2 digit bank display part of this, or multiplexed elsewhere WRITE8_MEMBER(ecoinf3_state::ppi8255_intf_e_write_a_alpha_display) { @@ -427,8 +424,7 @@ WRITE8_MEMBER(ecoinf3_state::ppi8255_intf_e_write_a_alpha_display) send_buffer = data; } - update_display(); - + std::transform(std::begin(m_chars), std::end(m_chars), std::begin(m_vfd_outputs), set_display); } ADDRESS_MAP_START(ecoinf3_state::pyramid_memmap) @@ -743,13 +739,13 @@ MACHINE_CONFIG_START(ecoinf3_state::ecoinf3_pyramid) MCFG_I8255_OUT_PORTC_CB(WRITE8(ecoinf3_state, ppi8255_intf_h_write_c)) MCFG_ECOIN_200STEP_ADD("reel0") - MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel0_optic_cb)) + MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel_optic_cb<0>)) MCFG_ECOIN_200STEP_ADD("reel1") - MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel1_optic_cb)) + MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel_optic_cb<1>)) MCFG_ECOIN_200STEP_ADD("reel2") - MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel2_optic_cb)) + MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel_optic_cb<2>)) MCFG_ECOIN_200STEP_ADD("reel3") - MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel3_optic_cb)) + MCFG_STEPPER_OPTIC_CALLBACK(WRITELINE(ecoinf3_state, reel_optic_cb<3>)) MACHINE_CONFIG_END diff --git a/src/mame/drivers/elekscmp.cpp b/src/mame/drivers/elekscmp.cpp index 4f60d6fb802..7fe1c306533 100644 --- a/src/mame/drivers/elekscmp.cpp +++ b/src/mame/drivers/elekscmp.cpp @@ -34,30 +34,36 @@ public: elekscmp_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") - , m_x0(*this, "X0") - , m_x1(*this, "X1") - , m_x2(*this, "X2") - , m_x3(*this, "X3") - { } + , m_x(*this, "X%u", 0U) + , m_digit(*this, "digit%u", 0U) + { } + + void elekscmp(machine_config &config); + +protected: + virtual void machine_start() override; DECLARE_READ8_MEMBER(keyboard_r); DECLARE_WRITE8_MEMBER(hex_display_w); uint8_t convert_key(uint8_t data); - void elekscmp(machine_config &config); void mem_map(address_map &map); + private: required_device m_maincpu; - required_ioport m_x0; - required_ioport m_x1; - required_ioport m_x2; - required_ioport m_x3; + required_ioport_array<4> m_x; + output_finder<8> m_digit; }; +void elekscmp_state::machine_start() +{ + m_digit.resolve(); +} + WRITE8_MEMBER(elekscmp_state::hex_display_w) { - output().set_digit_value(offset, data); + m_digit[offset & 0x7] = data; } uint8_t elekscmp_state::convert_key(uint8_t data) @@ -73,23 +79,19 @@ READ8_MEMBER(elekscmp_state::keyboard_r) { uint8_t data; - data = m_x0->read(); - + data = m_x[0]->read(); if (data) return 0x80 | convert_key(data); - data = m_x1->read(); - + data = m_x[1]->read(); if (data) return 0x88 | convert_key(data); - data = m_x2->read(); - + data = m_x[2]->read(); if (data) return 0x80 | (convert_key(data) << 4); - data = m_x3->read(); - + data = m_x[3]->read(); if (data) m_maincpu->reset(); diff --git a/src/mame/drivers/junior.cpp b/src/mame/drivers/junior.cpp index e8ca25c0036..dd4c158e88b 100644 --- a/src/mame/drivers/junior.cpp +++ b/src/mame/drivers/junior.cpp @@ -39,24 +39,34 @@ public: : driver_device(mconfig, type, tag) , m_riot(*this, "riot") , m_maincpu(*this, "maincpu") + , m_line(*this, "LINE%u", 0U) + , m_digit(*this, "digit%u", 0U) { } - required_device m_riot; + DECLARE_INPUT_CHANGED_MEMBER(junior_reset); + void junior(machine_config &config); + +protected: DECLARE_READ8_MEMBER(junior_riot_a_r); DECLARE_READ8_MEMBER(junior_riot_b_r); DECLARE_WRITE8_MEMBER(junior_riot_a_w); DECLARE_WRITE8_MEMBER(junior_riot_b_w); - uint8_t m_port_a; - uint8_t m_port_b; - uint8_t m_led_time[6]; + virtual void machine_start() override; virtual void machine_reset() override; - DECLARE_INPUT_CHANGED_MEMBER(junior_reset); TIMER_DEVICE_CALLBACK_MEMBER(junior_update_leds); - required_device m_maincpu; - void junior(machine_config &config); + void junior_mem(address_map &map); + +private: + required_device m_riot; + uint8_t m_port_a; + uint8_t m_port_b; + uint8_t m_led_time[6]; + required_device m_maincpu; + required_ioport_array<4> m_line; + output_finder<6> m_digit; }; @@ -130,16 +140,13 @@ READ8_MEMBER( junior_state::junior_riot_a_r ) { uint8_t data = 0xff; - switch( ( m_port_b >> 1 ) & 0x0f ) + uint8_t const sel = ( m_port_b >> 1) & 0x0f; + switch ( sel ) { case 0: - data = ioport("LINE0")->read(); - break; case 1: - data = ioport("LINE1")->read(); - break; case 2: - data = ioport("LINE2")->read(); + data = m_line[sel]->read(); break; } return data; @@ -165,7 +172,7 @@ WRITE8_MEMBER( junior_state::junior_riot_a_w ) if ((idx >= 4 && idx < 10) & ( m_port_a != 0xff )) { - output().set_digit_value( idx-4, m_port_a ^ 0x7f ); + m_digit[idx - 4] = m_port_a ^ 0x7f; m_led_time[idx - 4] = 10; } } @@ -179,7 +186,7 @@ WRITE8_MEMBER( junior_state::junior_riot_b_w ) if ((idx >= 4 && idx < 10) & ( m_port_a != 0xff )) { - output().set_digit_value( idx-4, m_port_a ^ 0x7f ); + m_digit[idx - 4] = m_port_a ^ 0x7f; m_led_time[idx - 4] = 10; } } @@ -194,15 +201,18 @@ TIMER_DEVICE_CALLBACK_MEMBER(junior_state::junior_update_leds) if ( m_led_time[i] ) m_led_time[i]--; else - output().set_digit_value( i, 0 ); + m_digit[i] = 0; } } void junior_state::machine_start() { + m_digit.resolve(); + save_item(NAME(m_port_a)); save_item(NAME(m_port_b)); + save_item(NAME(m_led_time)); } @@ -217,7 +227,7 @@ void junior_state::machine_reset() MACHINE_CONFIG_START(junior_state::junior) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu",M6502, XTAL(1'000'000)) + MCFG_CPU_ADD("maincpu",M6502, 1_MHz_XTAL) MCFG_CPU_PROGRAM_MAP(junior_mem) MCFG_QUANTUM_TIME(attotime::from_hz(50)) @@ -225,7 +235,7 @@ MACHINE_CONFIG_START(junior_state::junior) MCFG_DEFAULT_LAYOUT( layout_junior ) /* Devices */ - MCFG_DEVICE_ADD("riot", MOS6532_NEW, XTAL(1'000'000)) + MCFG_DEVICE_ADD("riot", MOS6532_NEW, 1_MHz_XTAL) MCFG_MOS6530n_IN_PA_CB(READ8(junior_state, junior_riot_a_r)) MCFG_MOS6530n_OUT_PA_CB(WRITE8(junior_state, junior_riot_a_w)) MCFG_MOS6530n_IN_PB_CB(READ8(junior_state, junior_riot_b_r)) diff --git a/src/mame/drivers/maxaflex.cpp b/src/mame/drivers/maxaflex.cpp index d44b05030d2..9976eb734ff 100644 --- a/src/mame/drivers/maxaflex.cpp +++ b/src/mame/drivers/maxaflex.cpp @@ -45,30 +45,37 @@ public: , m_console(*this, "console") , m_joy01(*this, "djoy_0_1") , m_joy23(*this, "djoy_2_3") + , m_lamp(*this, "lamp%u", 0U) + , m_digit(*this, "digit%u", 0U) { } - uint8_t m_portB_out; - uint8_t m_portC_out; + DECLARE_INPUT_CHANGED_MEMBER(coin_inserted); + void maxaflex(machine_config &config); + +protected: DECLARE_READ8_MEMBER(mcu_portA_r); DECLARE_WRITE8_MEMBER(mcu_portA_w); DECLARE_WRITE8_MEMBER(mcu_portB_w); DECLARE_WRITE8_MEMBER(mcu_portC_w); - DECLARE_INPUT_CHANGED_MEMBER(coin_inserted); DECLARE_READ8_MEMBER(pia_pa_r); DECLARE_READ8_MEMBER(pia_pb_r); WRITE8_MEMBER(pia_pb_w) { mmu(data); } WRITE_LINE_MEMBER(pia_cb2_w) { } // This is used by Floppy drive on Atari 8bits Home Computers TIMER_DEVICE_CALLBACK_MEMBER(mf_interrupt); - void maxaflex(machine_config &config); - void a600xl_mem(address_map &map); -protected: + virtual void machine_start() override; virtual void machine_reset() override; bool atari_input_disabled() const { return !BIT(m_portB_out, 7); } void mmu(uint8_t new_mmu); +private: + void a600xl_mem(address_map &map); + + uint8_t m_portB_out; + uint8_t m_portC_out; + required_device m_mcu; required_device m_speaker; required_region_ptr m_region_maincpu; @@ -77,6 +84,8 @@ protected: required_ioport m_console; required_ioport m_joy01; required_ioport m_joy23; + output_finder<4> m_lamp; + output_finder<3> m_digit; }; @@ -155,10 +164,10 @@ WRITE8_MEMBER(maxaflex_state::mcu_portB_w) /* latch for lamps */ if (BIT(diff, 6) && !BIT(data, 6)) { - output().set_lamp_value(0, BIT(m_portC_out, 0)); - output().set_lamp_value(1, BIT(m_portC_out, 1)); - output().set_lamp_value(2, BIT(m_portC_out, 2)); - output().set_lamp_value(3, BIT(m_portC_out, 3)); + m_lamp[0] = BIT(m_portC_out, 0); + m_lamp[1] = BIT(m_portC_out, 1); + m_lamp[2] = BIT(m_portC_out, 2); + m_lamp[3] = BIT(m_portC_out, 3); } } @@ -177,13 +186,9 @@ WRITE8_MEMBER(maxaflex_state::mcu_portC_w) m_portC_out = data & 0x0f; /* displays */ - switch (m_portB_out & 0x03) - { - case 0x0: output().set_digit_value(0, ls48_map[m_portC_out]); break; - case 0x1: output().set_digit_value(1, ls48_map[m_portC_out]); break; - case 0x2: output().set_digit_value(2, ls48_map[m_portC_out]); break; - case 0x3: break; - } + uint8_t const sel = m_portB_out & 0x03; + if (3U > sel) + m_digit[sel] = ls48_map[m_portC_out]; } INPUT_CHANGED_MEMBER(maxaflex_state::coin_inserted) @@ -285,8 +290,21 @@ READ8_MEMBER(maxaflex_state::pia_pb_r) } +void maxaflex_state::machine_start() +{ + atari_common_state::machine_start(); + + m_lamp.resolve(); + m_digit.resolve(); + + save_item(NAME(m_portB_out)); + save_item(NAME(m_portC_out)); +} + void maxaflex_state::machine_reset() { + atari_common_state::machine_reset(); + pokey_device *pokey = machine().device("pokey"); pokey->write(15,0); @@ -294,13 +312,8 @@ void maxaflex_state::machine_reset() m_portB_out = 0xff; m_portC_out = 0xff; - output().set_lamp_value(0, 0); - output().set_lamp_value(1, 0); - output().set_lamp_value(2, 0); - output().set_lamp_value(3, 0); - output().set_digit_value(0, 0x00); - output().set_digit_value(1, 0x00); - output().set_digit_value(2, 0x00); + std::fill(std::begin(m_lamp), std::end(m_lamp), 0); + std::fill(std::begin(m_digit), std::end(m_digit), 0x00); } TIMER_DEVICE_CALLBACK_MEMBER( maxaflex_state::mf_interrupt ) @@ -342,14 +355,14 @@ MACHINE_CONFIG_START(maxaflex_state::maxaflex) MCFG_SCREEN_PALETTE("palette") MCFG_PALETTE_ADD("palette", 256) - MCFG_PALETTE_INIT_OWNER(atari_common_state, atari) + MCFG_PALETTE_INIT_OWNER(maxaflex_state, atari) MCFG_DEFAULT_LAYOUT(layout_maxaflex) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("pokey", POKEY, pokey_device::FREQ_17_EXACT) - MCFG_POKEY_INTERRUPT_CB(atari_common_state, interrupt_cb) + MCFG_POKEY_INTERRUPT_CB(maxaflex_state, interrupt_cb) MCFG_POKEY_OUTPUT_RC(RES_K(1), CAP_U(0.0), 5.0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) diff --git a/src/mame/drivers/mpu3.cpp b/src/mame/drivers/mpu3.cpp index e00510a6655..c021390dfcd 100644 --- a/src/mame/drivers/mpu3.cpp +++ b/src/mame/drivers/mpu3.cpp @@ -165,7 +165,7 @@ TODO: - Distinguish door switches using manual #include "video/awpvid.h" //Fruit Machines Only -#define MPU3_MASTER_CLOCK (XTAL(4'000'000)) +static constexpr XTAL MPU3_MASTER_CLOCK = 4_MHz_XTAL; /* Lookup table for CHR data */ @@ -184,6 +184,9 @@ public: , m_reels(*this, "reel%u", 0U) , m_meters(*this, "meters") , m_vfd(*this, "vfd") + , m_triac(*this, "triac%u", 0U) + , m_digit(*this, "digit%u", 0U) + , m_lamp(*this, "lamp%u", 0U) { } DECLARE_DRIVER_INIT(m3hprvpr); @@ -224,7 +227,6 @@ protected: void ic11_update(); void ic21_output(int data); void ic21_setup(); - void mpu3_config_common(); virtual void machine_start() override; virtual void machine_reset() override; @@ -265,6 +267,9 @@ private: required_device_array m_reels; required_device m_meters; optional_device m_vfd; + output_finder<8> m_triac; + output_finder<8> m_digit; + output_finder<8 * 8> m_lamp; }; #define DISPLAY_PORT 0 @@ -274,14 +279,11 @@ private: void mpu3_state::update_triacs() { - int i,triacdata; + int const triacdata = m_triac_ic3 + (m_triac_ic4 << 8) + (m_triac_ic5 << 9); - triacdata=m_triac_ic3 + (m_triac_ic4 << 8) + (m_triac_ic5 << 9); - - for (i = 0; i < 8; i++) - { - output().set_indexed_value("triac", i, triacdata & (1 << i)); - } + // FIXME: m_triac_ic4 and m_triac_ic5 won't be used because they're shifted past what's checked here + for (int i = 0; i < 8; i++) + m_triac[i] = BIT(triacdata, i); } /* called if board is reset */ @@ -352,18 +354,17 @@ void mpu3_state::ic11_update() if (m_IC11G1) { if ( m_IC11GA ) m_input_strobe |= 0x01; - else m_input_strobe &= ~0x01; + else m_input_strobe &= ~0x01; if ( m_IC11GB ) m_input_strobe |= 0x02; - else m_input_strobe &= ~0x02; + else m_input_strobe &= ~0x02; if ( m_IC11GC ) m_input_strobe |= 0x04; - else m_input_strobe &= ~0x04; + else m_input_strobe &= ~0x04; } } } - else - if ((m_IC11G2A)||(m_IC11G2B)||(!m_IC11G1)) + else if ((m_IC11G2A)||(m_IC11G2B)||(!m_IC11G1)) { m_input_strobe = 0x00; } @@ -487,32 +488,31 @@ READ8_MEMBER(mpu3_state::pia_ic4_porta_r) /* IC4, 7 seg leds */ WRITE8_MEMBER(mpu3_state::pia_ic4_porta_w) { - int meter,swizzle; LOG(("%s: IC4 PIA Port A Set to %2x (DISPLAY PORT)\n", machine().describe_context(),data)); m_ic4_input_a=data; switch (m_disp_func) { - case DISPLAY_PORT: + case DISPLAY_PORT: if(m_ic11_active) { if(m_led_strobe != m_input_strobe) { - swizzle = ((m_ic4_input_a & 0x01) << 2)+(m_ic4_input_a & 0x02)+((m_ic4_input_a & 0x4) >> 2)+(m_ic4_input_a & 0x08)+((m_ic4_input_a & 0x10) << 2)+(m_ic4_input_a & 0x20)+((m_ic4_input_a & 0x40) >> 2); - output().set_digit_value(7 - m_input_strobe,swizzle); + int const swizzle = ((m_ic4_input_a & 0x01) << 2)+(m_ic4_input_a & 0x02)+((m_ic4_input_a & 0x4) >> 2)+(m_ic4_input_a & 0x08)+((m_ic4_input_a & 0x10) << 2)+(m_ic4_input_a & 0x20)+((m_ic4_input_a & 0x40) >> 2); + m_digit[7 - m_input_strobe] = swizzle; } m_led_strobe = m_input_strobe; } break; - case METER_PORT: - for (meter = 0; meter < 6; meter ++) + case METER_PORT: + for (int meter = 0; meter < 6; meter ++) { - swizzle = ((m_ic4_input_a ^ 0xff) & 0x3f); - m_meters->update(meter, (swizzle & (1 << meter))); + int const swizzle = ((m_ic4_input_a ^ 0xff) & 0x3f); + m_meters->update(meter, swizzle & (1 << meter)); } break; - case BWB_FUNCTIONALITY: + case BWB_FUNCTIONALITY: //Need to find a game to work this out, MFME has a specific option for it, but I see no activity there. break; @@ -522,8 +522,7 @@ WRITE8_MEMBER(mpu3_state::pia_ic4_porta_w) WRITE8_MEMBER(mpu3_state::pia_ic4_portb_w) { LOG(("%s: IC4 PIA Port B Set to %2x (Lamp)\n", machine().describe_context(),data)); - int i; - if(m_ic11_active) + if (m_ic11_active) { if (m_lamp_strobe != m_input_strobe) { @@ -531,10 +530,9 @@ WRITE8_MEMBER(mpu3_state::pia_ic4_portb_w) // As a consequence, the lamp column data can change before the input strobe (effectively writing 0 to the previous strobe) // without causing the relevant lamps to black out. - for (i = 0; i < 8; i++) - { - output().set_lamp_value((8*m_input_strobe)+i, ((data & (1 << i)) !=0)); - } + for (int i = 0; i < 8; i++) + m_lamp[(m_input_strobe << 3)|i] = BIT(data, i); + m_lamp_strobe = m_input_strobe; } } @@ -734,14 +732,13 @@ static INPUT_PORTS_START( mpu3 ) INPUT_PORTS_END /* Common configurations */ -void mpu3_state::mpu3_config_common() +void mpu3_state::machine_start() { m_ic21_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mpu3_state::ic21_timeout),this)); -} -void mpu3_state::machine_start() -{ - mpu3_config_common(); + m_triac.resolve(); + m_digit.resolve(); + m_lamp.resolve(); } /* Characteriser (CHR) diff --git a/src/mame/drivers/sitcom.cpp b/src/mame/drivers/sitcom.cpp index 2e77a776f41..557d3f0402e 100644 --- a/src/mame/drivers/sitcom.cpp +++ b/src/mame/drivers/sitcom.cpp @@ -60,10 +60,16 @@ public: , m_buttons(*this, "BUTTONS") , m_maincpu(*this, "maincpu") , m_bank(*this, "bank") + , m_leds(*this, "p%c%u", unsigned('a'), 0U) , m_rxd(true) { } + DECLARE_INPUT_CHANGED_MEMBER(update_buttons); + + void sitcom(machine_config &config); + +protected: template DECLARE_WRITE16_MEMBER(update_ds) { output().set_digit_value((D << 2) | offset, data); } DECLARE_WRITE_LINE_MEMBER(update_rxd) { m_rxd = bool(state); } DECLARE_WRITE_LINE_MEMBER(sod_led) { output().set_value("sod_led", state); } @@ -72,19 +78,17 @@ public: virtual DECLARE_WRITE8_MEMBER(update_pia_pa); virtual DECLARE_WRITE8_MEMBER(update_pia_pb); - DECLARE_INPUT_CHANGED_MEMBER(update_buttons); - - void sitcom(machine_config &config); void sitcom_bank(address_map &map); void sitcom_io(address_map &map); void sitcom_mem(address_map &map); -protected: + virtual void machine_start() override; virtual void machine_reset() override; required_ioport m_buttons; required_device m_maincpu; required_device m_bank; + output_finder<2, 8> m_leds; bool m_rxd; }; @@ -110,15 +114,16 @@ public: { } - virtual DECLARE_WRITE8_MEMBER(update_pia_pa) override; - virtual DECLARE_WRITE8_MEMBER(update_pia_pb) override; DECLARE_READ_LINE_MEMBER(shutter_r); - DECLARE_INPUT_CHANGED_MEMBER(update_shutter); DECLARE_INPUT_CHANGED_MEMBER(update_speed); void sitcomtmr(machine_config &config); + protected: + virtual DECLARE_WRITE8_MEMBER(update_pia_pa) override; + virtual DECLARE_WRITE8_MEMBER(update_pia_pb) override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; virtual void machine_start() override; @@ -201,6 +206,8 @@ INPUT_PORTS_END void sitcom_state::machine_start() { + m_leds.resolve(); + save_item(NAME(m_rxd)); m_rxd = true; @@ -214,13 +221,13 @@ void sitcom_state::machine_reset() WRITE8_MEMBER( sitcom_state::update_pia_pa ) { for (int i = 0; 8 > i; ++i) - output().set_indexed_value("pa", i, BIT(data, i)); + m_leds[0][i] = BIT(data, i); } WRITE8_MEMBER( sitcom_state::update_pia_pb ) { for (int i = 0; 8 > i; ++i) - output().set_indexed_value("pb", i, BIT(data, i)); + m_leds[1][i] = BIT(data, i); } INPUT_CHANGED_MEMBER( sitcom_state::update_buttons ) @@ -374,8 +381,9 @@ MACHINE_CONFIG_END MACHINE_CONFIG_START(sitcom_timer_state::sitcomtmr) sitcom(config); + MCFG_DEVICE_ADD("ds2", DL1414T, 0) // remote display - MCFG_DL1414_UPDATE_HANDLER(WRITE16(sitcom_state, update_ds<2>)) + MCFG_DL1414_UPDATE_HANDLER(WRITE16(sitcom_timer_state, update_ds<2>)) MCFG_DEFAULT_LAYOUT(layout_sitcomtmr) MACHINE_CONFIG_END diff --git a/src/mame/drivers/tk80.cpp b/src/mame/drivers/tk80.cpp index f2a53cdb5ae..0c2961c7cf9 100644 --- a/src/mame/drivers/tk80.cpp +++ b/src/mame/drivers/tk80.cpp @@ -60,8 +60,18 @@ public: tk80_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") + , m_digit(*this, "digit%u", 0U) { } + void ics8080(machine_config &config); + void tk80(machine_config &config); + void mikrolab(machine_config &config); + void nd80z(machine_config &config); + void tk85(machine_config &config); + +protected: + virtual void machine_start() override; + DECLARE_READ8_MEMBER(key_matrix_r); DECLARE_READ8_MEMBER(nd80z_key_r); DECLARE_READ8_MEMBER(serial_r); @@ -69,34 +79,45 @@ public: DECLARE_WRITE8_MEMBER(mikrolab_serial_w); DECLARE_READ8_MEMBER(display_r); DECLARE_WRITE8_MEMBER(display_w); - uint8_t m_term_data; - uint8_t m_keyb_press; - uint8_t m_keyb_press_flag; - uint8_t m_shift_press_flag; - uint8_t m_ppi_portc; - required_device m_maincpu; - void ics8080(machine_config &config); - void tk80(machine_config &config); - void mikrolab(machine_config &config); - void nd80z(machine_config &config); - void tk85(machine_config &config); + void ics8080_mem(address_map &map); void mikrolab_io(address_map &map); void nd80z_io(address_map &map); void tk80_io(address_map &map); void tk80_mem(address_map &map); void tk85_mem(address_map &map); + +private: + uint8_t m_term_data; + uint8_t m_keyb_press; + uint8_t m_keyb_press_flag; + uint8_t m_shift_press_flag; + uint8_t m_ppi_portc; + + required_device m_maincpu; + output_finder<8> m_digit; }; +void tk80_state::machine_start() +{ + m_digit.resolve(); + + save_item(NAME(m_term_data)); + save_item(NAME(m_keyb_press)); + save_item(NAME(m_keyb_press_flag)); + save_item(NAME(m_shift_press_flag)); + save_item(NAME(m_ppi_portc)); +} + READ8_MEMBER( tk80_state::display_r ) { - return output().get_digit_value(offset); + return m_digit[offset & 0x7]; } WRITE8_MEMBER( tk80_state::display_w ) { - output().set_digit_value(offset, data); + m_digit[offset & 0x7] = data; } ADDRESS_MAP_START(tk80_state::tk80_mem) @@ -204,7 +225,7 @@ INPUT_PORTS_END READ8_MEMBER( tk80_state::key_matrix_r ) { -// PA0-7 keyscan in + // PA0-7 keyscan in uint8_t data = 0xff; @@ -220,16 +241,14 @@ READ8_MEMBER( tk80_state::key_matrix_r ) READ8_MEMBER( tk80_state::nd80z_key_r ) { -// PA0-7 keyscan in + // PA0-7 keyscan in uint8_t data = 0xff, row = m_ppi_portc & 7; if (row == 6) data &= ioport("X0")->read(); - else - if (row == 5) + else if (row == 5) data &= ioport("X1")->read(); - else - if (row == 3) + else if (row == 3) data &= ioport("X2")->read(); return data; @@ -237,7 +256,7 @@ READ8_MEMBER( tk80_state::nd80z_key_r ) READ8_MEMBER( tk80_state::serial_r ) { -// PB0 - serial in + // PB0 - serial in //printf("B R\n"); return 0; @@ -245,17 +264,17 @@ READ8_MEMBER( tk80_state::serial_r ) WRITE8_MEMBER( tk80_state::serial_w ) { -// PC0 - serial out -// PC4-6 keyscan out -// PC7 - display on/off + // PC0 - serial out + // PC4-6 keyscan out + // PC7 - display on/off m_ppi_portc = data ^ 0x70; } WRITE8_MEMBER( tk80_state::mikrolab_serial_w ) { -// PC0 - serial out -// PC4-6 keyscan out -// PC7 - display on/off + // PC0 - serial out + // PC4-6 keyscan out + // PC7 - display on/off m_ppi_portc = data; } @@ -290,7 +309,7 @@ MACHINE_CONFIG_START(tk80_state::mikrolab) MACHINE_CONFIG_END MACHINE_CONFIG_START(tk80_state::nd80z) - MCFG_CPU_ADD("maincpu", Z80, XTAL(1'000'000)) // Sharp LH0080A, can't see writing on xtal + MCFG_CPU_ADD("maincpu", Z80, 1e6 ) // Sharp LH0080A, can't see writing on xtal MCFG_CPU_PROGRAM_MAP(tk85_mem) MCFG_CPU_IO_MAP(nd80z_io) @@ -355,8 +374,8 @@ ROM_END /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS -COMP( 1976, tk80, 0, 0, tk80, tk80, tk80_state, 0, "NEC", "TK-80", MACHINE_NO_SOUND_HW ) -COMP( 1980, nectk85, tk80, 0, tk85, tk80, tk80_state, 0, "NEC", "TK-85", MACHINE_NO_SOUND_HW ) -COMP( 19??, nd80z, tk80, 0, nd80z, tk80, tk80_state, 0, "Chunichi", "ND-80Z", MACHINE_NO_SOUND_HW ) -COMP( 19??, mikrolab, tk80, 0, mikrolab, mikrolab, tk80_state, 0, "", "Mikrolab KR580IK80", MACHINE_NO_SOUND_HW ) -COMP( 19??, ics8080, tk80, 0, ics8080, ics8080, tk80_state, 0, "", "ICS8080", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW ) +COMP( 1976, tk80, 0, 0, tk80, tk80, tk80_state, 0, "NEC", "TK-80", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +COMP( 1980, nectk85, tk80, 0, tk85, tk80, tk80_state, 0, "NEC", "TK-85", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +COMP( 19??, nd80z, tk80, 0, nd80z, tk80, tk80_state, 0, "Chunichi", "ND-80Z", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +COMP( 19??, mikrolab, tk80, 0, mikrolab, mikrolab, tk80_state, 0, "", "Mikrolab KR580IK80", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +COMP( 19??, ics8080, tk80, 0, ics8080, ics8080, tk80_state, 0, "", "ICS8080", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) diff --git a/src/mame/drivers/wacky_gator.cpp b/src/mame/drivers/wacky_gator.cpp index d445e5b14de..7837ba110fa 100644 --- a/src/mame/drivers/wacky_gator.cpp +++ b/src/mame/drivers/wacky_gator.cpp @@ -32,60 +32,61 @@ class wackygtr_state : public driver_device { public: - wackygtr_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + wackygtr_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_msm(*this, "msm"), m_pit8253_0(*this, "pit8253_0"), m_pit8253_1(*this, "pit8253_1"), m_ticket(*this, "ticket"), - m_samples(*this, "oki") + m_samples(*this, "oki"), + m_alligator(*this, "alligator%u", 0U), + m_digit(*this, "digit%u", 0U), + m_lamp(*this, "lamp%u", 0U) { } - required_device m_maincpu; - required_device m_msm; - required_device m_pit8253_0; - required_device m_pit8253_1; - required_device m_ticket; - required_memory_region m_samples; + DECLARE_CUSTOM_INPUT_MEMBER(alligators_rear_sensors_r); + DECLARE_CUSTOM_INPUT_MEMBER(alligators_front_sensors_r); + + void wackygtr(machine_config &config); - DECLARE_DRIVER_INIT(wackygtr); - void machine_reset() override; +protected: + virtual void machine_start() override; + virtual void machine_reset() override; DECLARE_WRITE_LINE_MEMBER(adpcm_int); DECLARE_WRITE8_MEMBER(sample_ctrl_w); DECLARE_WRITE8_MEMBER(alligators_ctrl1_w); DECLARE_WRITE8_MEMBER(alligators_ctrl2_w); - DECLARE_CUSTOM_INPUT_MEMBER(alligators_rear_sensors_r); - DECLARE_CUSTOM_INPUT_MEMBER(alligators_front_sensors_r); void set_lamps(int p, uint8_t value); DECLARE_WRITE8_MEMBER(status_lamps_w); - DECLARE_WRITE8_MEMBER(timing_lamps_0_w) { set_lamps(8 , data); } - DECLARE_WRITE8_MEMBER(timing_lamps_1_w) { set_lamps(16, data); } - DECLARE_WRITE8_MEMBER(timing_lamps_2_w) { set_lamps(24, data); } + template DECLARE_WRITE8_MEMBER(timing_lamps_w) { set_lamps((N + 1) << 3, data); } void set_digits(int p, uint8_t value); - DECLARE_WRITE8_MEMBER(disp0_w) { set_digits(0, data); } - DECLARE_WRITE8_MEMBER(disp1_w) { set_digits(2, data); } - DECLARE_WRITE8_MEMBER(disp2_w) { set_digits(4, data); } - DECLARE_WRITE8_MEMBER(disp3_w) { set_digits(6, data); } + template DECLARE_WRITE8_MEMBER(disp_w) { set_digits(N << 1, data); } void pmm8713_ck(int i, int state); - DECLARE_WRITE_LINE_MEMBER(alligator0_ck) { pmm8713_ck(0, state); } - DECLARE_WRITE_LINE_MEMBER(alligator1_ck) { pmm8713_ck(1, state); } - DECLARE_WRITE_LINE_MEMBER(alligator2_ck) { pmm8713_ck(2, state); } - DECLARE_WRITE_LINE_MEMBER(alligator3_ck) { pmm8713_ck(3, state); } - DECLARE_WRITE_LINE_MEMBER(alligator4_ck) { pmm8713_ck(4, state); } + template DECLARE_WRITE_LINE_MEMBER(alligator_ck) { pmm8713_ck(N, state); } DECLARE_WRITE8_MEMBER(irq_ack_w) { m_maincpu->set_input_line(M6809_IRQ_LINE, CLEAR_LINE); } DECLARE_WRITE8_MEMBER(firq_ack_w) { m_maincpu->set_input_line(M6809_FIRQ_LINE, CLEAR_LINE); } TIMER_DEVICE_CALLBACK_MEMBER(nmi_timer) { m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); } - void wackygtr(machine_config &config); void program_map(address_map &map); + private: + required_device m_maincpu; + required_device m_msm; + required_device m_pit8253_0; + required_device m_pit8253_1; + required_device m_ticket; + required_memory_region m_samples; + output_finder<5> m_alligator; + output_finder<8> m_digit; + output_finder<32> m_lamp; + int m_adpcm_sel; uint16_t m_adpcm_pos; uint8_t m_adpcm_ctrl; @@ -95,10 +96,6 @@ private: }; -DRIVER_INIT_MEMBER(wackygtr_state, wackygtr) -{ -} - WRITE8_MEMBER(wackygtr_state::status_lamps_w) { /* @@ -161,7 +158,7 @@ void wackygtr_state::pmm8713_ck(int i, int state) int alligator_state = m_motors_pos[i] / 10; if (alligator_state > 5) alligator_state = 5; if (alligator_state < 0) alligator_state = 0; - output().set_indexed_value("alligator", i, alligator_state); + m_alligator[i] = alligator_state; } } @@ -184,6 +181,19 @@ CUSTOM_INPUT_MEMBER(wackygtr_state::alligators_front_sensors_r) ((m_motors_pos[4] < 5 || m_motors_pos[4] > 55) ? 0x10 : 0); } +void wackygtr_state::machine_start() +{ + m_alligator.resolve(); + m_digit.resolve(); + m_lamp.resolve(); + + save_item(NAME(m_adpcm_sel)); + save_item(NAME(m_adpcm_pos)); + save_item(NAME(m_adpcm_ctrl)); + save_item(NAME(m_alligators_ctrl)); + save_item(NAME(m_motors_pos)); +} + void wackygtr_state::machine_reset() { m_adpcm_pos = 0; @@ -193,15 +203,15 @@ void wackygtr_state::machine_reset() void wackygtr_state::set_digits(int p, uint8_t value) { - static uint8_t bcd2hex[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67, 0, 0, 0, 0, 0, 0 }; // not accurate - output().set_digit_value(p + 0, bcd2hex[value & 0x0f]); - output().set_digit_value(p + 1, bcd2hex[(value >> 4) & 0x0f]); + static constexpr uint8_t bcd2hex[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67, 0, 0, 0, 0, 0, 0 }; // not accurate + m_digit[p + 0] = bcd2hex[value & 0x0f]; + m_digit[p + 1] = bcd2hex[(value >> 4) & 0x0f]; } void wackygtr_state::set_lamps(int p, uint8_t value) { - for(int i=0; i<8; i++) - output().set_lamp_value(p + i, BIT(value, i)); + for (int i=0; i<8; i++) + m_lamp[p + i] = BIT(value, i); } static INPUT_PORTS_START( wackygtr ) @@ -254,10 +264,10 @@ WRITE_LINE_MEMBER(wackygtr_state::adpcm_int) ADDRESS_MAP_START(wackygtr_state::program_map) AM_RANGE(0x0200, 0x0200) AM_READNOP AM_WRITE(irq_ack_w) AM_RANGE(0x0400, 0x0400) AM_READNOP AM_WRITE(firq_ack_w) - AM_RANGE(0x0600, 0x0600) AM_WRITE(disp0_w) - AM_RANGE(0x0800, 0x0800) AM_WRITE(disp1_w) - AM_RANGE(0x0a00, 0x0a00) AM_WRITE(disp2_w) - AM_RANGE(0x0c00, 0x0c00) AM_WRITE(disp3_w) + AM_RANGE(0x0600, 0x0600) AM_WRITE(disp_w<0>) + AM_RANGE(0x0800, 0x0800) AM_WRITE(disp_w<1>) + AM_RANGE(0x0a00, 0x0a00) AM_WRITE(disp_w<2>) + AM_RANGE(0x0c00, 0x0c00) AM_WRITE(disp_w<3>) AM_RANGE(0x0e00, 0x0e00) AM_WRITE(sample_ctrl_w) AM_RANGE(0x1000, 0x1001) AM_DEVWRITE("ymsnd", ym2413_device, write) @@ -300,9 +310,9 @@ MACHINE_CONFIG_START(wackygtr_state::wackygtr) MCFG_I8255_OUT_PORTC_CB(WRITE8(wackygtr_state, alligators_ctrl2_w)) MCFG_DEVICE_ADD("i8255_1", I8255, 0) - MCFG_I8255_OUT_PORTA_CB(WRITE8(wackygtr_state, timing_lamps_0_w)) - MCFG_I8255_OUT_PORTB_CB(WRITE8(wackygtr_state, timing_lamps_1_w)) - MCFG_I8255_OUT_PORTC_CB(WRITE8(wackygtr_state, timing_lamps_2_w)) + MCFG_I8255_OUT_PORTA_CB(WRITE8(wackygtr_state, timing_lamps_w<0>)) + MCFG_I8255_OUT_PORTB_CB(WRITE8(wackygtr_state, timing_lamps_w<1>)) + MCFG_I8255_OUT_PORTC_CB(WRITE8(wackygtr_state, timing_lamps_w<2>)) MCFG_DEVICE_ADD("i8255_2", I8255, 0) MCFG_I8255_IN_PORTA_CB(IOPORT("IN0")) @@ -311,19 +321,19 @@ MACHINE_CONFIG_START(wackygtr_state::wackygtr) MCFG_DEVICE_ADD("pit8253_0", PIT8253, 0) MCFG_PIT8253_CLK0(XTAL(3'579'545)/16) // this is a guess - MCFG_PIT8253_OUT0_HANDLER(WRITELINE(wackygtr_state, alligator0_ck)) + MCFG_PIT8253_OUT0_HANDLER(WRITELINE(wackygtr_state, alligator_ck<0>)) MCFG_PIT8253_CLK1(XTAL(3'579'545)/16) // this is a guess - MCFG_PIT8253_OUT1_HANDLER(WRITELINE(wackygtr_state, alligator1_ck)) + MCFG_PIT8253_OUT1_HANDLER(WRITELINE(wackygtr_state, alligator_ck<1>)) MCFG_PIT8253_CLK2(XTAL(3'579'545)/16) // this is a guess - MCFG_PIT8253_OUT2_HANDLER(WRITELINE(wackygtr_state, alligator2_ck)) + MCFG_PIT8253_OUT2_HANDLER(WRITELINE(wackygtr_state, alligator_ck<2>)) MCFG_DEVICE_ADD("pit8253_1", PIT8253, 0) MCFG_PIT8253_CLK0(XTAL(3'579'545)/16) // this is a guess MCFG_PIT8253_OUT0_HANDLER(INPUTLINE("maincpu", M6809_FIRQ_LINE)) MCFG_PIT8253_CLK1(XTAL(3'579'545)/16) // this is a guess - MCFG_PIT8253_OUT1_HANDLER(WRITELINE(wackygtr_state, alligator3_ck)) + MCFG_PIT8253_OUT1_HANDLER(WRITELINE(wackygtr_state, alligator_ck<3>)) MCFG_PIT8253_CLK2(XTAL(3'579'545)/16) // this is a guess - MCFG_PIT8253_OUT2_HANDLER(WRITELINE(wackygtr_state, alligator4_ck)) + MCFG_PIT8253_OUT2_HANDLER(WRITELINE(wackygtr_state, alligator_ck<4>)) MCFG_TICKET_DISPENSER_ADD("ticket", attotime::from_msec(200), TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH) MACHINE_CONFIG_END @@ -337,4 +347,4 @@ ROM_START( wackygtr ) ROM_LOAD("wp3-vo0.2h", 0x0000, 0x10000, CRC(91c7986f) SHA1(bc9fa0d41c1caa0f909a349f511d022b7e42c6cd)) ROM_END -GAME(1990, wackygtr, 0, wackygtr, wackygtr, wackygtr_state, wackygtr, ROT0, "Data East", "Wacky Gator", MACHINE_IS_SKELETON_MECHANICAL | MACHINE_CLICKABLE_ARTWORK) +GAME(1990, wackygtr, 0, wackygtr, wackygtr, wackygtr_state, 0, ROT0, "Data East", "Wacky Gator", MACHINE_IS_SKELETON_MECHANICAL | MACHINE_CLICKABLE_ARTWORK) diff --git a/src/mame/includes/alesis.h b/src/mame/includes/alesis.h index 5f84c1a9daf..2df687cf4c3 100644 --- a/src/mame/includes/alesis.h +++ b/src/mame/includes/alesis.h @@ -59,28 +59,32 @@ private: class alesis_state : public driver_device { public: - alesis_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_lcdc(*this, "hd44780"), - m_cassette(*this, "cassette"), - m_maincpu(*this, "maincpu"), - m_col1(*this, "COL1"), - m_col2(*this, "COL2"), - m_col3(*this, "COL3"), - m_col4(*this, "COL4"), - m_col5(*this, "COL5"), - m_col6(*this, "COL6"), - m_select(*this, "SELECT") + alesis_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_lcdc(*this, "hd44780"), + m_cassette(*this, "cassette"), + m_maincpu(*this, "maincpu"), + m_col1(*this, "COL1"), + m_col2(*this, "COL2"), + m_col3(*this, "COL3"), + m_col4(*this, "COL4"), + m_col5(*this, "COL5"), + m_col6(*this, "COL6"), + m_select(*this, "SELECT"), + m_track_led(*this, "track_led%u", 1U) { } - required_device m_lcdc; - optional_device m_cassette; + DECLARE_DRIVER_INIT(hr16); + void mmt8(machine_config &config); + void hr16(machine_config &config); + void sr16(machine_config &config); +protected: DECLARE_PALETTE_INIT(alesis); + virtual void machine_start() override; virtual void machine_reset() override; void update_lcd_symbols(bitmap_ind16 &bitmap, uint8_t pos, uint8_t y, uint8_t x, int state); - DECLARE_DRIVER_INIT(hr16); DECLARE_WRITE8_MEMBER( led_w ); DECLARE_WRITE8_MEMBER( mmt8_led_w ); DECLARE_READ8_MEMBER( mmt8_led_r ); @@ -94,19 +98,21 @@ public: DECLARE_WRITE8_MEMBER( sr16_lcd_w ); HD44780_PIXEL_UPDATE(sr16_pixel_update); - void mmt8(machine_config &config); - void hr16(machine_config &config); - void sr16(machine_config &config); void hr16_io(address_map &map); void hr16_mem(address_map &map); void mmt8_io(address_map &map); void sr16_io(address_map &map); void sr16_mem(address_map &map); + private: uint8_t m_kb_matrix; uint8_t m_leds; uint8_t m_lcd_digits[5]; + + required_device m_lcdc; + optional_device m_cassette; required_device m_maincpu; + required_ioport m_col1; required_ioport m_col2; required_ioport m_col3; @@ -114,6 +120,7 @@ private: required_ioport m_col5; required_ioport m_col6; optional_ioport m_select; + output_finder<8> m_track_led; }; // device type definition diff --git a/src/mame/includes/atari400.h b/src/mame/includes/atari400.h index a2fedf7abbc..beb351b96b4 100644 --- a/src/mame/includes/atari400.h +++ b/src/mame/includes/atari400.h @@ -11,14 +11,16 @@ ******************************************************************************/ -#ifndef MAME_INCLUDES_ATARI_H -#define MAME_INCLUDES_ATARI_H +#ifndef MAME_INCLUDES_ATARI400_H +#define MAME_INCLUDES_ATARI400_H #include "machine/6821pia.h" #include "sound/pokey.h" #include "video/antic.h" #include "video/gtia.h" +#include + class atari_common_state : public driver_device { @@ -32,8 +34,9 @@ public: , m_keypad(*this, "keypad.%u", 0) , m_djoy_b(*this, "djoy_b") , m_fake(*this, "fake") - { } + { } +protected: virtual void video_start() override; DECLARE_PALETTE_INIT(atari); @@ -42,7 +45,6 @@ public: POKEY_KEYBOARD_CB_MEMBER(a5200_keypads); POKEY_KEYBOARD_CB_MEMBER(a800_keyboard); -protected: required_device m_maincpu; required_device m_gtia; required_device m_antic; @@ -52,4 +54,4 @@ protected: optional_ioport m_fake; }; -#endif // MAME_INCLUDES_ATARI_H +#endif // MAME_INCLUDES_ATARI400_H diff --git a/src/mame/includes/bfm_sc4.h b/src/mame/includes/bfm_sc4.h index beea529a6e1..547bb35d11a 100644 --- a/src/mame/includes/bfm_sc4.h +++ b/src/mame/includes/bfm_sc4.h @@ -86,22 +86,26 @@ static const uint8_t SEGMENT_34_ENCODING_LOOKUP[16] = // common base class for things shared between sc4 and sc5 class bfm_sc45_state : public driver_device { -public: +protected: bfm_sc45_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_duart(*this, "duart68681"), - m_vfd0(*this, "vfd0"), - m_dm01(*this, "dm01"), - m_ymz(*this, "ymz") + : driver_device(mconfig, type, tag) + , m_duart(*this, "duart68681") + , m_vfd0(*this, "vfd0") + , m_dm01(*this, "dm01") + , m_ymz(*this, "ymz") + , m_lamps(*this, "lamp%u", 0U) + , m_matrix(*this, "matrix%u", 0U) + , m_digits(*this, "digit%u", 0U) { } -public: - required_device m_duart; optional_device m_vfd0; optional_device m_dm01; required_device m_ymz; + output_finder<0x20 * 8> m_lamps; + output_finder<0x20 * 8> m_matrix; + output_finder<32 + 2> m_digits; // serial vfd int vfd_enabled; @@ -114,6 +118,8 @@ public: bool m_segment_34_encoding; uint8_t m_segment_34_cache[32]; + virtual void machine_start() override; + DECLARE_WRITE8_MEMBER(mux_output_w); DECLARE_WRITE8_MEMBER(mux_output2_w); void bfm_sc4_reset_serial_vfd(); @@ -606,11 +612,8 @@ public: DECLARE_DRIVER_INIT(sc4corotb); DECLARE_DRIVER_INIT(sc4hyper); - - - DECLARE_MACHINE_START(sc4); - DECLARE_MACHINE_RESET(sc4); - + virtual void machine_start() override; + virtual void machine_reset() override; void bfm_sc4_68307_porta_w(address_space &space, bool dedicated, uint8_t data, uint8_t line_mask); DECLARE_WRITE8_MEMBER( bfm_sc4_reel3_w ); @@ -647,6 +650,7 @@ public: void sc4_no_reels(machine_config &config); void sc4dmd(machine_config &config); void sc4_map(address_map &map); + protected: optional_ioport_array<16> m_io_ports; }; @@ -655,16 +659,17 @@ class sc4_adder4_state : public sc4_state { public: sc4_adder4_state(const machine_config &mconfig, device_type type, const char *tag) - : sc4_state(mconfig, type, tag), - m_adder4cpu(*this, "adder4") + : sc4_state(mconfig, type, tag) + , m_adder4cpuregion(*this, "adder4") + , m_adder4cpu(*this, "adder4") { } - uint32_t* m_adder4cpuregion; + required_region_ptr m_adder4cpuregion; std::unique_ptr m_adder4ram; DECLARE_READ32_MEMBER(adder4_mem_r); DECLARE_WRITE32_MEMBER(adder4_mem_w); - DECLARE_MACHINE_START(adder4); + virtual void machine_start() override; // devices required_device m_adder4cpu; diff --git a/src/mame/includes/sms.h b/src/mame/includes/sms.h index 1d887a56b5e..b58c4c52332 100644 --- a/src/mame/includes/sms.h +++ b/src/mame/includes/sms.h @@ -36,8 +36,8 @@ class sms_state : public driver_device { public: - sms_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + sms_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_vdp(*this, "sms_vdp"), m_main_scr(*this, "screen"), @@ -55,6 +55,7 @@ public: m_port_scope(*this, "SEGASCOPE"), m_port_scope_binocular(*this, "SSCOPE_BINOCULAR"), m_port_persist(*this, "PERSISTENCE"), + m_led_pwr(*this, "led_pwr"), m_region_maincpu(*this, "maincpu"), m_mainram(nullptr), m_is_gamegear(0), @@ -66,7 +67,8 @@ public: m_has_bios_2000(0), m_has_bios_full(0), m_has_jpn_sms_cart_slot(0), - m_store_cart_selection_data(0) { } + m_store_cart_selection_data(0) + { } // devices required_device m_maincpu; @@ -88,6 +90,8 @@ public: optional_ioport m_port_scope_binocular; optional_ioport m_port_persist; + output_finder<> m_led_pwr; + required_memory_region m_region_maincpu; address_space *m_space; std::unique_ptr m_mainram; @@ -263,9 +267,9 @@ protected: class smssdisp_state : public sms_state { public: - smssdisp_state(const machine_config &mconfig, device_type type, const char *tag) - : sms_state(mconfig, type, tag), - m_control_cpu(*this, "control") + smssdisp_state(const machine_config &mconfig, device_type type, const char *tag) : + sms_state(mconfig, type, tag), + m_control_cpu(*this, "control") { } required_device m_control_cpu; diff --git a/src/mame/layout/acrnsys1.lay b/src/mame/layout/acrnsys1.lay index 63d0e132e90..9d5d9f49f57 100644 --- a/src/mame/layout/acrnsys1.lay +++ b/src/mame/layout/acrnsys1.lay @@ -26,31 +26,31 @@ - + - + - + - + - + - + - + - + - + diff --git a/src/mame/machine/esqlcd.cpp b/src/mame/machine/esqlcd.cpp index 9fdb8c42390..46bc432733d 100644 --- a/src/mame/machine/esqlcd.cpp +++ b/src/mame/machine/esqlcd.cpp @@ -8,7 +8,8 @@ #include "esqlcd.h" #include "esq2by16.lh" -//#define VERBOSE +//#define VERBOSE 1 +#include "logmacro.h" DEFINE_DEVICE_TYPE(ESQ2X16_SQ1, esq2x16_sq1_device, "esq2x16_sq1", "Ensoniq 2x16 VFD (SQ-1 variant)") @@ -188,33 +189,24 @@ void esq2x16_sq1_device::write_char(int data) case 0x87: // Go To - #ifdef VERBOSE - printf("LCD %02X: Go To %02X - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Go To %02X - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); m_lcdPos = DisplayCode; m_lcd_command = 0; return; - break; case 0x88: // Save Cursor position - What the second byte (00 or 01) means? - #ifdef VERBOSE - printf("LCD %02X: Save Pos. (%02X) - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Save Pos. (%02X) - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); m_lcdSavedPos = m_lcdPos; m_lcd_command = 0; return; - break; case 0x89: // Restore Cursor position - What the second byte (00 or 01) means? - #ifdef VERBOSE - printf("LCD %02X: Restore Pos. (%02X) - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Restore Pos. (%02X) - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); m_lcdPos = m_lcdSavedPos; m_lcd_command = 0; return; - break; case 0x8D: case 0x8E: @@ -229,37 +221,25 @@ void esq2x16_sq1_device::write_char(int data) DisplayCode == 15 // non-existent ) { - #ifdef VERBOSE - printf("LCD %02X: Led %02d does'nt exist - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Led %02d doesn't exist - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); } else { - if (m_leds[DisplayCode] != LedState) - { - m_leds[DisplayCode] = LedState; - m_ledsDirty[DisplayCode] = 1; - } + m_leds[DisplayCode] = LedState; update_display(); } m_lcd_command = 0; return; - break; default: - #ifdef VERBOSE - printf("LCD: Unknown 2-Bytes Command:%02X-%02X - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD: Unknown 2-Bytes Command:%02X-%02X - pos=%02X (%d)\n", m_lcd_command, DisplayCode, m_lcdPos, m_lcdPage); m_lcd_command = 0; return; - break; } if ((data >= 0x20) && (data <= 0x7f)) { - #ifdef VERBOSE - printf("LCD %02X: \"%c\" - pos=%02X (%d)\n", DisplayCode, data, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: \"%c\" - pos=%02X (%d)\n", DisplayCode, data, m_lcdPos, m_lcdPage); m_lcdpg[m_lcdPage][m_lcdPos++] = DisplayCode; if (m_lcdPos > 31) m_lcdPos = 31; @@ -277,7 +257,6 @@ void esq2x16_sq1_device::write_char(int data) // Save the command for the next byte m_lcd_command = DisplayCode; return; - break; // Unknown 2-bytes command case 0x85: @@ -286,7 +265,6 @@ void esq2x16_sq1_device::write_char(int data) // ??? - related to blinking chars? - 2 bytes command m_lcd_command = DisplayCode; return; - break; case 0x8D: case 0x8E: @@ -294,95 +272,79 @@ void esq2x16_sq1_device::write_char(int data) // LEDs OFF,ON and BLINK - 2 bytes command m_lcd_command = DisplayCode; return; - break; // "Page" selectors (?) case 0x90: // Blink case 0x91: // ?? case 0x92: // Normal m_lcdPage = DisplayCode & 0x03; - #ifdef VERBOSE - printf("LCD %02X: Page Change ? - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Page Change ? - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); m_lcd_command = 0; return; - break; case 0x8C: - #ifdef VERBOSE - printf("LCD %02X: Lcd Clear - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Lcd Clear - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); lcd_reset(); return; - break; case 0x98: - #ifdef VERBOSE - printf("LCD %02X: Page Clear ? - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Page Clear ? - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); page_reset(); return; - break; default: - #ifdef VERBOSE - printf("LCD %02X: Unknown Command - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); - #endif + LOG("LCD %02X: Unknown Command - pos=%02X (%d)\n", DisplayCode, m_lcdPos, m_lcdPage); m_lcd_command = 0; return; - break; } } - #ifdef VERBOSE else { - printf("LCD: Unknown LCD Code: %04X - pos=%02X (%d)\n", data, m_lcdPos, m_lcdPage); + LOG("LCD: Unknown LCD Code: %04X - pos=%02X (%d)\n", data, m_lcdPos, m_lcdPage); } - #endif } //-------------------------------------------------------------------------------------------------------------------------------------------- -esq2x16_sq1_device::esq2x16_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X16_SQ1, tag, owner, clock) +esq2x16_sq1_device::esq2x16_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + esqvfd_device(mconfig, ESQ2X16_SQ1, tag, owner, clock, 2, 16), + m_lcdPix(*this, "pg_%u%03u", 1U, 0U), + m_leds(*this, "rLed_%u", 0U) { - m_rows = 2; - m_cols = 16; } //-------------------------------------------------------------------------------------------------------------------------------------------- void esq2x16_sq1_device::update_display() { - char lcdCharRow; - - for (int led = 0; led < 16; led++) - { - if (m_ledsDirty[led]) { - machine().output().set_indexed_value("rLed_", led, m_leds[led]); - m_ledsDirty[led] = 0; - } - } - for (int page = 0; page < 4; page++) { for (int pos = 0; pos < 32; pos++) { // stealed from tecnbras.cpp and modified - for (int rr=0; rr<7; rr++) { - lcdCharRow = rotate_lcd_char(m_lcdpg[page][pos],rr); - machine().output().set_indexed_value("pg_", (page+1)*1000 + pos*7 + rr, 0x1F & lcdCharRow); + for (int rr = 0; rr < 7; rr++) + { + char lcdCharRow = rotate_lcd_char(m_lcdpg[page][pos],rr); + m_lcdPix[page][pos*7 + rr] = 0x1f & lcdCharRow; } } } } //-------------------------------------------------------------------------------------------------------------------------------------------- +void esq2x16_sq1_device::device_start() +{ + esqvfd_device::device_start(); + m_lcdPix.resolve(); + m_leds.resolve(); +} +//-------------------------------------------------------------------------------------------------------------------------------------------- void esq2x16_sq1_device::device_reset() { //lcd_reset(); m_lcdPage = m_lcdSavedPos = m_lcdPos = m_lcd_command = 0; - memset(m_leds, 0, sizeof(m_leds)); + for (auto &led : m_leds) led = 0; memset(m_lcdpg, 1, sizeof(m_lcdpg)); // Set to 1 for debug: to see what "pages" are set to 0 from the firmware } //-------------------------------------------------------------------------------------------------------------------------------------------- void esq2x16_sq1_device::lcd_reset() { m_lcdPage = m_lcdSavedPos = m_lcdPos = m_lcd_command = 0; - memset(m_leds, 0, sizeof(m_leds)); + for (auto &led : m_leds) led = 0; memset(m_lcdpg, 0, sizeof(m_lcdpg)); } //-------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/src/mame/machine/esqlcd.h b/src/mame/machine/esqlcd.h index eb5e09f6bff..ae0bc6c089d 100644 --- a/src/mame/machine/esqlcd.h +++ b/src/mame/machine/esqlcd.h @@ -25,14 +25,15 @@ public: protected: virtual void device_add_mconfig(machine_config &config) override; + virtual void device_start() override; virtual void device_reset() override; uint8_t m_lcdpg[4][32]; int m_lcdPage; - int m_lcdPos,m_lcdSavedPos; + int m_lcdPos, m_lcdSavedPos; + output_finder<4, 32*7> m_lcdPix; - uint8_t m_leds[16]; - uint8_t m_ledsDirty[16]; + output_finder<16> m_leds; private: void lcd_reset(); diff --git a/src/mame/machine/esqvfd.cpp b/src/mame/machine/esqvfd.cpp index 4201b8cb885..3b85885d4c4 100644 --- a/src/mame/machine/esqvfd.cpp +++ b/src/mame/machine/esqvfd.cpp @@ -116,8 +116,10 @@ static const uint16_t font[]= 0x0000, // 0000 0000 0000 0000 (DEL) }; -esqvfd_device::esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, type, tag, owner, clock) +esqvfd_device::esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rows, int cols) : + device_t(mconfig, type, tag, owner, clock), + m_rows(rows), + m_cols(cols) { } @@ -177,9 +179,7 @@ void esqvfd_device::update_display() // force bottom bar on all underlined chars if (m_attrs[row][col] & AT_UNDERLINE) - { segdata |= 0x0008; - } machine().output().set_indexed_value("vfd", (row*m_cols) + col, segdata); @@ -317,10 +317,8 @@ bool esq2x40_device::write_contents(std::ostream &o) } -esq2x40_device::esq2x40_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X40, tag, owner, clock) +esq2x40_device::esq2x40_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X40, tag, owner, clock, 2, 40) { - m_rows = 2; - m_cols = 40; } /* 1x22 display from the VFX (not right, but it'll do for now) */ @@ -366,10 +364,8 @@ void esq1x22_device::write_char(int data) update_display(); } -esq1x22_device::esq1x22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ1X22, tag, owner, clock) +esq1x22_device::esq1x22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ1X22, tag, owner, clock, 1, 22) { - m_rows = 1; - m_cols = 22; } /* SQ-1 display, I think it's really an LCD but we'll deal with it for now */ @@ -429,10 +425,8 @@ void esq2x40_sq1_device::write_char(int data) } } -esq2x40_sq1_device::esq2x40_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X40_SQ1, tag, owner, clock) +esq2x40_sq1_device::esq2x40_sq1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : esqvfd_device(mconfig, ESQ2X40_SQ1, tag, owner, clock, 2, 40) { - m_rows = 2; - m_cols = 40; m_wait87shift = false; m_wait88shift = false; } diff --git a/src/mame/machine/esqvfd.h b/src/mame/machine/esqvfd.h index 63b12ea2d90..fcb0505d94c 100644 --- a/src/mame/machine/esqvfd.h +++ b/src/mame/machine/esqvfd.h @@ -33,7 +33,7 @@ public: uint32_t conv_segments(uint16_t segin); protected: - esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + esqvfd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rows, int cols); static constexpr uint8_t AT_NORMAL = 0x00; static constexpr uint8_t AT_BOLD = 0x01; @@ -47,7 +47,7 @@ protected: int m_cursx, m_cursy; int m_savedx, m_savedy; - int m_rows, m_cols; + int const m_rows, m_cols; uint8_t m_curattr; uint8_t m_lastchar; uint8_t m_chars[2][40]; diff --git a/src/mame/machine/model2.cpp b/src/mame/machine/model2.cpp index b4fb1d427b1..8a714e1b39b 100644 --- a/src/mame/machine/model2.cpp +++ b/src/mame/machine/model2.cpp @@ -12,6 +12,9 @@ #include "debug/debugcon.h" #include "debug/debugcmd.h" #include "debugger.h" + +#include + void model2_state::debug_init() { @@ -54,59 +57,57 @@ void model2_state::debug_help_command(int ref, const std::vector &p void model2_state::debug_geo_dasm_command(int ref, const std::vector ¶ms) { debugger_console &con = machine().debugger().console(); - FILE *f; - + if (params.size() < 2) { con.printf("Error: not enough parameters for m2 geodasm command\n"); return; } - + if (params[1].empty() || params[1].length() > 127) { con.printf("Error: invalid filename parameter for m2 geodasm command\n"); return; } - if((f = fopen( params[1].c_str(), "w" )) == nullptr) + std::ofstream f(params[1]); + if (!f) { con.printf("Error: while opening %s for writing\n",params[1].c_str()); return; } - - int ptr; - bool end_code = false; - + // print some basic info on top - fprintf(f, "Dump Header info:\n"); - fprintf(f, "GEO address: %08x %08x\n",m_geo_read_start_address+0x900000,m_geo_write_start_address+0x900000); - fprintf(f, "Screen Info: %lld %d %d\n",m_screen->frame_number(),m_screen->hpos(),m_screen->vpos()); - fprintf(f, "====================\n"); + util::stream_format(f, "Dump Header info:\n"); + util::stream_format(f, "GEO address: %08x %08x\n",m_geo_read_start_address+0x900000,m_geo_write_start_address+0x900000); + util::stream_format(f, "Screen Info: %d %d %d\n",m_screen->frame_number(),m_screen->hpos(),m_screen->vpos()); + util::stream_format(f, "====================\n"); - ptr = m_geo_read_start_address/4; + int ptr = m_geo_read_start_address/4; + bool end_code = false; - while(end_code == false && ptr < 0x20000/4) + while (!end_code && ptr < 0x20000/4) { uint32_t opcode; uint32_t attr; - - fprintf(f, "%08x: \t",ptr*4+0x900000); + + util::stream_format(f, "%08x: \t",ptr*4+0x900000); opcode = m_bufferram[ptr++]; - + // parse jump opcode if(opcode & 0x80000000) { // exit if the operand is illegal if(opcode & ~0x8001ffff) { - fprintf(f, "(illegal jump)"); + util::stream_format(f, "(illegal jump)"); end_code = true; } else { // jump and print into dasm ptr = (opcode & 0x1ffff) / 4; - fprintf(f, "jump %08x",opcode & 0x1ffff); + util::stream_format(f, "jump %08x",opcode & 0x1ffff); } } else @@ -117,16 +118,16 @@ void model2_state::debug_geo_dasm_command(int ref, const std::vector> 23) & 0x1f); + util::stream_format(f, "unk %02x",(opcode >> 23) & 0x1f); break; } } // append the raw opcode and new line here - fprintf(f,"\t%08x\n",opcode); + util::stream_format(f,"\t%08x\n",opcode); } - - fclose( f ); + + f.close(); con.printf("Data dumped successfully\n"); } diff --git a/src/mame/machine/sms.cpp b/src/mame/machine/sms.cpp index c7c958e9c37..1e37ac62a73 100644 --- a/src/mame/machine/sms.cpp +++ b/src/mame/machine/sms.cpp @@ -297,7 +297,7 @@ WRITE_LINE_MEMBER(sms_state::sms_csync_callback) // It switches between on/off at each 2048 C-Sync pulses. if ((m_csync_counter & 0x7ff) == 0) { - output().set_led_value(0, !output().get_led_value(0)); + m_led_pwr = !m_led_pwr; } } else // Rapid Fire disabled @@ -1025,6 +1025,8 @@ void sms_state::setup_bios() MACHINE_START_MEMBER(sms_state,sms) { + m_led_pwr.resolve(); + char str[7]; m_cartslot = machine().device("slot"); -- cgit v1.2.3-70-g09d2