From b8aff36f3cb48c753f4bf21399665d2c6a4efba5 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Mon, 17 Dec 2018 17:27:52 +0100 Subject: src/mame: penutlimate batch of MCFG macros define removal (nw) --- src/mame/drivers/angelkds.cpp | 22 +++---- src/mame/drivers/appoooh.cpp | 17 +++--- src/mame/drivers/calorie.cpp | 15 ++--- src/mame/drivers/dccons.cpp | 40 +++++++++++-- src/mame/drivers/naomi.cpp | 107 +++++++++++++++++++++++++++++------ src/mame/drivers/segae.cpp | 15 ++--- src/mame/machine/dc-ctrl.cpp | 7 +-- src/mame/machine/dc-ctrl.h | 52 +++++++---------- src/mame/machine/mapledev.cpp | 4 +- src/mame/machine/mapledev.h | 15 ++--- src/mame/machine/mie.cpp | 27 ++++----- src/mame/machine/mie.h | 34 +++++------ src/mame/machine/segacrp2_device.cpp | 19 ++++--- src/mame/machine/segacrp2_device.h | 10 ++-- 14 files changed, 225 insertions(+), 159 deletions(-) diff --git a/src/mame/drivers/angelkds.cpp b/src/mame/drivers/angelkds.cpp index 55135a7deee..f5835bd438a 100644 --- a/src/mame/drivers/angelkds.cpp +++ b/src/mame/drivers/angelkds.cpp @@ -13,7 +13,7 @@ Both games appear to be joint Sega / Nasco efforts but I think that has something to do with Nasco ) Space Position is encrypted, the main processor is -D317-0005 (NEC Z80 Custom), see machine/segacrpt.c +D317-0005 (NEC Z80 Custom), see machine/segacrpt.cpp for details on this encryption scheme */ @@ -519,7 +519,7 @@ void angelkds_state::machine_reset() MACHINE_CONFIG_START(angelkds_state::angelkds) - MCFG_DEVICE_ADD("maincpu", Z80, XTAL(6'000'000)) + MCFG_DEVICE_ADD(m_maincpu, Z80, XTAL(6'000'000)) MCFG_DEVICE_PROGRAM_MAP(main_map) MCFG_DEVICE_IO_MAP(main_portmap) MCFG_DEVICE_VBLANK_INT_DRIVER("screen", angelkds_state, irq0_line_hold) @@ -571,17 +571,17 @@ MACHINE_CONFIG_START(angelkds_state::angelkds) MCFG_SOUND_ROUTE(3, "mono", 0.45) MACHINE_CONFIG_END -MACHINE_CONFIG_START(angelkds_state::spcpostn) +void angelkds_state::spcpostn(machine_config &config) +{ angelkds(config); /* encryption */ - MCFG_DEVICE_REPLACE("maincpu", SEGA_317_0005, XTAL(6'000'000)) - MCFG_DEVICE_PROGRAM_MAP(main_map) - MCFG_DEVICE_IO_MAP(main_portmap) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", angelkds_state, irq0_line_hold) - MCFG_DEVICE_OPCODES_MAP(decrypted_opcodes_map) - MCFG_SEGAZ80_SET_DECRYPTED_TAG(":decrypted_opcodes") - -MACHINE_CONFIG_END + sega_317_0005_device &maincpu(SEGA_317_0005(config.replace(), m_maincpu, XTAL(6'000'000))); + maincpu.set_addrmap(AS_PROGRAM, &angelkds_state::main_map); + maincpu.set_addrmap(AS_IO, &angelkds_state::main_portmap); + maincpu.set_vblank_int("screen", FUNC(angelkds_state::irq0_line_hold)); + maincpu.set_addrmap(AS_OPCODES, &angelkds_state::decrypted_opcodes_map); + maincpu.set_decrypted_tag(m_decrypted_opcodes); +} /*** Rom Loading diff --git a/src/mame/drivers/appoooh.cpp b/src/mame/drivers/appoooh.cpp index dba029a9678..4fbd4eaaff7 100644 --- a/src/mame/drivers/appoooh.cpp +++ b/src/mame/drivers/appoooh.cpp @@ -487,16 +487,17 @@ MACHINE_CONFIG_START(appoooh_state::robowres) MCFG_PALETTE_INIT_OWNER(appoooh_state,robowres) MACHINE_CONFIG_END -MACHINE_CONFIG_START(appoooh_state::robowrese) +void appoooh_state::robowrese(machine_config &config) +{ robowres(config); - MCFG_DEVICE_REPLACE("maincpu", SEGA_315_5179,18432000/6) /* ??? the main xtal is 18.432 MHz */ - MCFG_DEVICE_PROGRAM_MAP(main_map) - MCFG_DEVICE_IO_MAP(main_portmap) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", appoooh_state, vblank_irq) - MCFG_DEVICE_OPCODES_MAP(decrypted_opcodes_map) - MCFG_SEGAZ80_SET_DECRYPTED_TAG(":decrypted_opcodes") -MACHINE_CONFIG_END + sega_315_5179_device &maincpu(SEGA_315_5179(config.replace(), m_maincpu, 18432000/6)); /* ??? the main xtal is 18.432 MHz */ + maincpu.set_addrmap(AS_PROGRAM, &appoooh_state::main_map); + maincpu.set_addrmap(AS_IO, &appoooh_state::main_portmap); + maincpu.set_vblank_int("screen", FUNC(appoooh_state::vblank_irq)); + maincpu.set_addrmap(AS_OPCODES, &appoooh_state::decrypted_opcodes_map); + maincpu.set_decrypted_tag(m_decrypted_opcodes); +} /************************************* * diff --git a/src/mame/drivers/calorie.cpp b/src/mame/drivers/calorie.cpp index 1361c8fe495..7bae3130d80 100644 --- a/src/mame/drivers/calorie.cpp +++ b/src/mame/drivers/calorie.cpp @@ -503,14 +503,15 @@ MACHINE_CONFIG_START(calorie_state::calorie) YM2149(config, "ay3", 1500000).add_route(ALL_OUTPUTS, "mono", 0.8); MACHINE_CONFIG_END -MACHINE_CONFIG_START(calorie_state::caloriee) +void calorie_state::caloriee(machine_config &config) +{ calorie(config); - MCFG_DEVICE_REPLACE("maincpu", SEGA_317_0004,4000000) /* 4 MHz */ - MCFG_DEVICE_PROGRAM_MAP(calorie_map) - MCFG_DEVICE_OPCODES_MAP(decrypted_opcodes_map) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", calorie_state, irq0_line_hold) - MCFG_SEGAZ80_SET_DECRYPTED_TAG(":decrypted_opcodes") -MACHINE_CONFIG_END + sega_317_0004_device &maincpu(SEGA_317_0004(config.replace(), m_maincpu, 4000000)); /* 4 MHz */ + maincpu.set_addrmap(AS_PROGRAM, &calorie_state::calorie_map); + maincpu.set_addrmap(AS_OPCODES, &calorie_state::decrypted_opcodes_map); + maincpu.set_vblank_int("screen", FUNC(calorie_state::irq0_line_hold)); + maincpu.set_decrypted_tag(m_decrypted_opcodes); +} /************************************* * diff --git a/src/mame/drivers/dccons.cpp b/src/mame/drivers/dccons.cpp index dd2572d3388..df01fc36ca5 100644 --- a/src/mame/drivers/dccons.cpp +++ b/src/mame/drivers/dccons.cpp @@ -608,10 +608,42 @@ MACHINE_CONFIG_START(dc_cons_state::dc) MAPLE_DC(config, m_maple, 0, m_maincpu); m_maple->irq_callback().set(FUNC(dc_state::maple_irq)); - MCFG_DC_CONTROLLER_ADD("dcctrl0", "maple_dc", 0, ":P1:0", ":P1:1", ":P1:A0", ":P1:A1", ":P1:A2", ":P1:A3", ":P1:A4", ":P1:A5") - MCFG_DC_CONTROLLER_ADD("dcctrl1", "maple_dc", 1, ":P2:0", ":P2:1", ":P2:A0", ":P2:A1", ":P2:A2", ":P2:A3", ":P2:A4", ":P2:A5") - MCFG_DC_CONTROLLER_ADD("dcctrl2", "maple_dc", 2, ":P3:0", ":P3:1", ":P3:A0", ":P3:A1", ":P3:A2", ":P3:A3", ":P3:A4", ":P3:A5") - MCFG_DC_CONTROLLER_ADD("dcctrl3", "maple_dc", 3, ":P4:0", ":P4:1", ":P4:A0", ":P4:A1", ":P4:A2", ":P4:A3", ":P4:A4", ":P4:A5") + dc_controller_device &dcctrl0(DC_CONTROLLER(config, "dcctrl0", 0, m_maple, 0)); + dcctrl0.set_port_tag<0>("P1:0"); + dcctrl0.set_port_tag<1>("P1:1"); + dcctrl0.set_port_tag<2>("P1:A0"); + dcctrl0.set_port_tag<3>("P1:A1"); + dcctrl0.set_port_tag<4>("P1:A2"); + dcctrl0.set_port_tag<5>("P1:A3"); + dcctrl0.set_port_tag<6>("P1:A4"); + dcctrl0.set_port_tag<7>("P1:A5"); + dc_controller_device &dcctrl1(DC_CONTROLLER(config, "dcctrl1", 0, m_maple, 1)); + dcctrl1.set_port_tag<0>("P2:0"); + dcctrl1.set_port_tag<1>("P2:1"); + dcctrl1.set_port_tag<2>("P2:A0"); + dcctrl1.set_port_tag<3>("P2:A1"); + dcctrl1.set_port_tag<4>("P2:A2"); + dcctrl1.set_port_tag<5>("P2:A3"); + dcctrl1.set_port_tag<6>("P2:A4"); + dcctrl1.set_port_tag<7>("P2:A5"); + dc_controller_device &dcctrl2(DC_CONTROLLER(config, "dcctrl2", 0, m_maple, 2)); + dcctrl2.set_port_tag<0>("P3:0"); + dcctrl2.set_port_tag<1>("P3:1"); + dcctrl2.set_port_tag<2>("P3:A0"); + dcctrl2.set_port_tag<3>("P3:A1"); + dcctrl2.set_port_tag<4>("P3:A2"); + dcctrl2.set_port_tag<5>("P3:A3"); + dcctrl2.set_port_tag<6>("P3:A4"); + dcctrl2.set_port_tag<7>("P3:A5"); + dc_controller_device &dcctrl3(DC_CONTROLLER(config, "dcctrl3", 0, m_maple, 3)); + dcctrl3.set_port_tag<0>("P4:0"); + dcctrl3.set_port_tag<1>("P4:1"); + dcctrl3.set_port_tag<2>("P4:A0"); + dcctrl3.set_port_tag<3>("P4:A1"); + dcctrl3.set_port_tag<4>("P4:A2"); + dcctrl3.set_port_tag<5>("P4:A3"); + dcctrl3.set_port_tag<6>("P4:A4"); + dcctrl3.set_port_tag<7>("P4:A5"); /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) diff --git a/src/mame/drivers/naomi.cpp b/src/mame/drivers/naomi.cpp index 0e4753f86e5..593a113e2c7 100644 --- a/src/mame/drivers/naomi.cpp +++ b/src/mame/drivers/naomi.cpp @@ -2954,7 +2954,10 @@ MACHINE_CONFIG_START(naomi_state::naomi_base) // - using UART as timer - 13.260MHz, // - unrolled NOPs then GPIO toggle - 12.76MHz (or 3.19M NOP instructions per second) // for now we use higher clock, otherwise earlier NAOMI BIOS revisions will not boot (see MT#06552). - MCFG_MIE_ADD("mie", 16000000, "maple_dc", 0, nullptr, nullptr, nullptr, ":MIE.3", nullptr, ":MIE.5", nullptr, nullptr) + mie_device &mie(MIE(config, "mie" "_maple", 16000000, m_maple, 0, "mie")); + mie.set_gpio_name<3>("MIE.3"); + mie.set_gpio_name<5>("MIE.5"); + MIE_JVS(config, "mie", 16000000); sega_837_13551_device &sega837(SEGA_837_13551(config, "837_13551", 0, "mie")); sega837.set_port_tag<0>("TILT"); @@ -3037,21 +3040,55 @@ void naomi_state::naomim4(machine_config &config) * Naomi M2 with Keyboard controllers */ -MACHINE_CONFIG_START(naomi_state::naomim2_kb) +void naomi_state::naomim2_kb(machine_config &config) +{ naomim2(config); - MCFG_DC_KEYBOARD_ADD("dcctrl0", "maple_dc", 1, ":P1.M", ":P1.LD", ":P1.KC1", ":P1.KC2", ":P1.KC3", ":P1.KC4", ":P1.KC5", ":P1.KC6") - MCFG_DC_KEYBOARD_ADD("dcctrl1", "maple_dc", 2, ":P2.M", ":P2.LD", ":P2.KC1", ":P2.KC2", ":P2.KC3", ":P2.KC4", ":P2.KC5", ":P2.KC6") -MACHINE_CONFIG_END + dc_keyboard_device &dcctrl0(DC_KEYBOARD(config, "dcctrl0", 0, m_maple, 1)); + dcctrl0.set_port_tag<0>("P1.M"); + dcctrl0.set_port_tag<1>("P1.LD"); + dcctrl0.set_port_tag<2>("P1.KC1"); + dcctrl0.set_port_tag<3>("P1.KC2"); + dcctrl0.set_port_tag<4>("P1.KC3"); + dcctrl0.set_port_tag<5>("P1.KC4"); + dcctrl0.set_port_tag<6>("P1.KC5"); + dcctrl0.set_port_tag<7>("P1.KC6"); + dc_keyboard_device &dcctrl1(DC_KEYBOARD(config, "dcctrl1", 0, m_maple, 2)); + dcctrl1.set_port_tag<0>("P2.M"); + dcctrl1.set_port_tag<1>("P2.LD"); + dcctrl1.set_port_tag<2>("P2.KC1"); + dcctrl1.set_port_tag<3>("P2.KC2"); + dcctrl1.set_port_tag<4>("P2.KC3"); + dcctrl1.set_port_tag<5>("P2.KC4"); + dcctrl1.set_port_tag<6>("P2.KC5"); + dcctrl1.set_port_tag<7>("P2.KC6"); +} /* * Naomi GD with Keyboard controllers */ -MACHINE_CONFIG_START(naomi_state::naomigd_kb) +void naomi_state::naomigd_kb(machine_config &config) +{ naomigd(config); - MCFG_DC_KEYBOARD_ADD("dcctrl0", "maple_dc", 1, ":P1.M", ":P1.LD", ":P1.KC1", ":P1.KC2", ":P1.KC3", ":P1.KC4", ":P1.KC5", ":P1.KC6") - MCFG_DC_KEYBOARD_ADD("dcctrl1", "maple_dc", 2, ":P2.M", ":P2.LD", ":P2.KC1", ":P2.KC2", ":P2.KC3", ":P2.KC4", ":P2.KC5", ":P2.KC6") -MACHINE_CONFIG_END + dc_keyboard_device &dcctrl0(DC_KEYBOARD(config, "dcctrl0", 0, m_maple, 1)); + dcctrl0.set_port_tag<0>("P1.M"); + dcctrl0.set_port_tag<1>("P1.LD"); + dcctrl0.set_port_tag<2>("P1.KC1"); + dcctrl0.set_port_tag<3>("P1.KC2"); + dcctrl0.set_port_tag<4>("P1.KC3"); + dcctrl0.set_port_tag<5>("P1.KC4"); + dcctrl0.set_port_tag<6>("P1.KC5"); + dcctrl0.set_port_tag<7>("P1.KC6"); + dc_keyboard_device &dcctrl1(DC_KEYBOARD(config, "dcctrl1", 0, m_maple, 2)); + dcctrl1.set_port_tag<0>("P2.M"); + dcctrl1.set_port_tag<1>("P2.LD"); + dcctrl1.set_port_tag<2>("P2.KC1"); + dcctrl1.set_port_tag<3>("P2.KC2"); + dcctrl1.set_port_tag<4>("P2.KC3"); + dcctrl1.set_port_tag<5>("P2.KC4"); + dcctrl1.set_port_tag<6>("P2.KC5"); + dcctrl1.set_port_tag<7>("P2.KC6"); +} /* * Naomi 2 @@ -3126,25 +3163,59 @@ MACHINE_CONFIG_START(atomiswave_state::aw_base) NVRAM(config, "sram", nvram_device::DEFAULT_ALL_0); MACHINE_CONFIG_END -MACHINE_CONFIG_START(atomiswave_state::aw1c) +void atomiswave_state::aw1c(machine_config &config) +{ aw_base(config); - MCFG_DC_CONTROLLER_ADD("dcctrl0", "maple_dc", 0, ":P1.0", ":P1.1", ":P1.A0", ":P1.A1", ":P1.A2", ":P1.A3", ":P1.A4", ":P1.A5") + dc_controller_device &dcctrl0(DC_CONTROLLER(config, "dcctrl0", 0, m_maple, 0)); + dcctrl0.set_port_tag<0>("P1.0"); + dcctrl0.set_port_tag<1>("P1.1"); + dcctrl0.set_port_tag<2>("P1.A0"); + dcctrl0.set_port_tag<3>("P1.A1"); + dcctrl0.set_port_tag<4>("P1.A2"); + dcctrl0.set_port_tag<5>("P1.A3"); + dcctrl0.set_port_tag<6>("P1.A4"); + dcctrl0.set_port_tag<7>("P1.A5"); // TODO: isn't it supposed to be just one controller? - MCFG_DC_CONTROLLER_ADD("dcctrl1", "maple_dc", 1, ":P2.0", ":P2.1", ":P2.A0", ":P2.A1", ":P2.A2", ":P2.A3", ":P2.A4", ":P2.A5") -MACHINE_CONFIG_END + dc_controller_device &dcctrl1(DC_CONTROLLER(config, "dcctrl1", 0, m_maple, 1)); + dcctrl1.set_port_tag<0>("P2.0"); + dcctrl1.set_port_tag<1>("P2.1"); + dcctrl1.set_port_tag<2>("P2.A0"); + dcctrl1.set_port_tag<3>("P2.A1"); + dcctrl1.set_port_tag<4>("P2.A2"); + dcctrl1.set_port_tag<5>("P2.A3"); + dcctrl1.set_port_tag<6>("P2.A4"); + dcctrl1.set_port_tag<7>("P2.A5"); +} -MACHINE_CONFIG_START(atomiswave_state::aw2c) +void atomiswave_state::aw2c(machine_config &config) +{ aw_base(config); - MCFG_DC_CONTROLLER_ADD("dcctrl0", "maple_dc", 0, ":P1.0", ":P1.1", ":P1.A0", ":P1.A1", ":P1.A2", ":P1.A3", ":P1.A4", ":P1.A5") - MCFG_DC_CONTROLLER_ADD("dcctrl1", "maple_dc", 1, ":P2.0", ":P2.1", ":P2.A0", ":P2.A1", ":P2.A2", ":P2.A3", ":P2.A4", ":P2.A5") -MACHINE_CONFIG_END + dc_controller_device &dcctrl0(DC_CONTROLLER(config, "dcctrl0", 0, m_maple, 0)); + dcctrl0.set_port_tag<0>("P1.0"); + dcctrl0.set_port_tag<1>("P1.1"); + dcctrl0.set_port_tag<2>("P1.A0"); + dcctrl0.set_port_tag<3>("P1.A1"); + dcctrl0.set_port_tag<4>("P1.A2"); + dcctrl0.set_port_tag<5>("P1.A3"); + dcctrl0.set_port_tag<6>("P1.A4"); + dcctrl0.set_port_tag<7>("P1.A5"); + dc_controller_device &dcctrl1(DC_CONTROLLER(config, "dcctrl1", 0, m_maple, 1)); + dcctrl1.set_port_tag<0>("P2.0"); + dcctrl1.set_port_tag<1>("P2.1"); + dcctrl1.set_port_tag<2>("P2.A0"); + dcctrl1.set_port_tag<3>("P2.A1"); + dcctrl1.set_port_tag<4>("P2.A2"); + dcctrl1.set_port_tag<5>("P2.A3"); + dcctrl1.set_port_tag<6>("P2.A4"); + dcctrl1.set_port_tag<7>("P2.A5"); +} #define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \ ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_BIOS(bios)) /* BIOS info: -Revisions through C supports only motherboards with X76F100 seral number eeprom +Revisions through C supports only motherboards with X76F100 serial number eeprom Revisions through D can handle game carts only Revisions C and later can also handle Multi-board Revisions E and later can also handle DIMM board diff --git a/src/mame/drivers/segae.cpp b/src/mame/drivers/segae.cpp index 0bdaa32e98c..9fd3d468b2b 100644 --- a/src/mame/drivers/segae.cpp +++ b/src/mame/drivers/segae.cpp @@ -952,14 +952,15 @@ MACHINE_CONFIG_START(systeme_state::systemex) MCFG_DEVICE_OPCODES_MAP(decrypted_opcodes_map) MACHINE_CONFIG_END -MACHINE_CONFIG_START(systeme_state::systemex_315_5177) +void systeme_state::systemex_315_5177(machine_config &config) +{ systeme(config); - MCFG_DEVICE_REPLACE("maincpu", SEGA_315_5177, XTAL(10'738'635)/2) /* Z80B @ 5.3693Mhz */ - MCFG_DEVICE_PROGRAM_MAP(systeme_map) - MCFG_DEVICE_IO_MAP(io_map) - MCFG_DEVICE_OPCODES_MAP(decrypted_opcodes_map) - MCFG_SEGAZ80_SET_DECRYPTED_TAG(":decrypted_opcodes") -MACHINE_CONFIG_END + sega_315_5177_device &maincpu(SEGA_315_5177(config.replace(), m_maincpu, XTAL(10'738'635)/2)); /* Z80B @ 5.3693Mhz */ + maincpu.set_addrmap(AS_PROGRAM, &systeme_state::systeme_map); + maincpu.set_addrmap(AS_IO, &systeme_state::io_map); + maincpu.set_addrmap(AS_OPCODES, &systeme_state::decrypted_opcodes_map); + maincpu.set_decrypted_tag(m_decrypted_opcodes); +} MACHINE_CONFIG_START(systeme_state::systemeb) systeme(config); diff --git a/src/mame/machine/dc-ctrl.cpp b/src/mame/machine/dc-ctrl.cpp index 30861245381..fe2925fcf0b 100644 --- a/src/mame/machine/dc-ctrl.cpp +++ b/src/mame/machine/dc-ctrl.cpp @@ -11,18 +11,13 @@ dc_common_device::dc_common_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : maple_device(mconfig, type, tag, owner, clock) + , port(*this, {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG}) { - memset(port_tag, 0, sizeof(port_tag)); } void dc_common_device::device_start() { maple_device::device_start(); - - for (int i = 0; i < 8; i++) - { - port[i] = ioport(port_tag[i]); - } } void dc_common_device::maple_w(const uint32_t *data, uint32_t in_size) diff --git a/src/mame/machine/dc-ctrl.h b/src/mame/machine/dc-ctrl.h index 3b0aab2898d..bc22a757111 100644 --- a/src/mame/machine/dc-ctrl.h +++ b/src/mame/machine/dc-ctrl.h @@ -7,25 +7,6 @@ #include "mapledev.h" -#define MCFG_DC_CONTROLLER_ADD(_tag, _host_tag, _host_port, d0, d1, a0, a1, a2, a3, a4, a5) \ - MCFG_MAPLE_DEVICE_ADD(_tag, DC_CONTROLLER, 0, _host_tag, _host_port) \ - downcast(*device).set_port_tag(0, d0); \ - downcast(*device).set_port_tag(1, d1); \ - downcast(*device).set_port_tag(2, a0); \ - downcast(*device).set_port_tag(3, a1); \ - downcast(*device).set_port_tag(4, a2); \ - downcast(*device).set_port_tag(5, a3); \ - downcast(*device).set_port_tag(6, a4); \ - downcast(*device).set_port_tag(7, a5); - -#define MCFG_DC_CONTROLLER_SET_MODEL(name) \ - downcast(*device).set_model(name); - -#define MCFG_DC_CONTROLLER_SET_LICENSE(license) \ - downcast(*device).set_license(license); - -#define MCFG_DC_CONTROLLER_SET_VERSIONS(versions) \ - ddowncast(*device).set_versions(versions); class dc_common_device : public maple_device { @@ -33,7 +14,8 @@ public: // construction/destruction dc_common_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - void set_port_tag(int port, const char *tag) { port_tag[port] = tag; } + template + void set_port_tag(T &&port_tag) { port[Which].set_tag(std::forward(port_tag)); } // TODO: we probably don't need these setters void set_model(const char *new_id) { model = new_id; } void set_license(const char *new_license) { license = new_license; } @@ -45,13 +27,12 @@ protected: // device-level overrides virtual void device_start() override; - const char *port_tag[8]; const char *model, *license, *versions; uint32_t id; uint32_t electric_current; uint32_t region; - ioport_port *port[8]; + optional_ioport_array<8> port; virtual void fixed_status(uint32_t *dest) = 0; virtual void free_status(uint32_t *dest) = 0; @@ -62,6 +43,14 @@ class dc_controller_device : public dc_common_device { public: // construction/destruction + template + dc_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&host_tag, int host_port) + : dc_controller_device(mconfig, tag, owner, clock) + { + host.set_tag(std::forward(host_tag)); + set_host_port(host_port); + } + dc_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); private: @@ -70,22 +59,19 @@ private: void read(uint32_t *dest) override; }; -#define MCFG_DC_KEYBOARD_ADD(_tag, _host_tag, _host_port, d0, d1, a0, a1, a2, a3, a4, a5) \ - MCFG_MAPLE_DEVICE_ADD(_tag, DC_KEYBOARD, 0, _host_tag, _host_port) \ - downcast(*device).set_port_tag(0, d0); \ - downcast(*device).set_port_tag(1, d1); \ - downcast(*device).set_port_tag(2, a0); \ - downcast(*device).set_port_tag(3, a1); \ - downcast(*device).set_port_tag(4, a2); \ - downcast(*device).set_port_tag(5, a3); \ - downcast(*device).set_port_tag(6, a4); \ - downcast(*device).set_port_tag(7, a5); - class dc_keyboard_device : public dc_common_device { public: // construction/destruction + template + dc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&host_tag, int host_port) + : dc_keyboard_device(mconfig, tag, owner, clock) + { + host.set_tag(std::forward(host_tag)); + set_host_port(host_port); + } + dc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); //protected: diff --git a/src/mame/machine/mapledev.cpp b/src/mame/machine/mapledev.cpp index 3ff8c096990..4279f21eb71 100644 --- a/src/mame/machine/mapledev.cpp +++ b/src/mame/machine/mapledev.cpp @@ -2,18 +2,16 @@ // copyright-holders:Olivier Galibert #include "emu.h" #include "mapledev.h" -#include "maple-dc.h" maple_device::maple_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) +, host(*this, finder_base::DUMMY_TAG) { - host_tag = nullptr; host_port = 0; } void maple_device::device_start() { - host = machine().device(host_tag); host->register_port(host_port, this); timer = timer_alloc(TIMER_ID); diff --git a/src/mame/machine/mapledev.h b/src/mame/machine/mapledev.h index 8dca02e8a63..cbf020a8470 100644 --- a/src/mame/machine/mapledev.h +++ b/src/mame/machine/mapledev.h @@ -3,18 +3,14 @@ #ifndef MAME_MACHINE_MAPLEDEV_H #define MAME_MACHINE_MAPLEDEV_H -#define MCFG_MAPLE_DEVICE_ADD(_tag, _type, _clock, _host_tag, _host_port) \ - MCFG_DEVICE_ADD(_tag, _type, _clock) \ - downcast(*device).set_host(_host_tag, _host_port); + +#include "maple-dc.h" class maple_device : public device_t { public: - void set_host(const char *_host_tag, int _host_port) - { - host_tag = _host_tag; - host_port = _host_port; - } + void set_host_port(int _host_port) { host_port = _host_port; } + virtual void maple_w(const uint32_t *data, uint32_t in_size) = 0; void maple_r(uint32_t *data, uint32_t &out_size, bool &partial); virtual void maple_reset(); @@ -43,8 +39,7 @@ protected: void reply_start(uint8_t code, uint8_t source, uint8_t size); // Configuration - class maple_dc_device *host; - const char *host_tag; + required_device host; int host_port; private: diff --git a/src/mame/machine/mie.cpp b/src/mame/machine/mie.cpp index 2b26c7bebe3..a1088358076 100644 --- a/src/mame/machine/mie.cpp +++ b/src/mame/machine/mie.cpp @@ -65,12 +65,13 @@ const tiny_rom_entry *mie_device::device_rom_region() const return ROM_NAME(mie); } -MACHINE_CONFIG_START(mie_device::device_add_mconfig) - MCFG_DEVICE_ADD("mie", Z80, DERIVED_CLOCK(1,1)) - MCFG_DEVICE_PROGRAM_MAP(mie_map) - MCFG_DEVICE_IO_MAP(mie_port) - MCFG_DEVICE_IRQ_ACKNOWLEDGE_DEVICE(DEVICE_SELF, mie_device, irq_callback) -MACHINE_CONFIG_END +void mie_device::device_add_mconfig(machine_config &config) +{ + Z80(config, cpu, DERIVED_CLOCK(1,1)); + cpu->set_addrmap(AS_PROGRAM, &mie_device::mie_map); + cpu->set_addrmap(AS_IO, &mie_device::mie_port); + cpu->set_irq_acknowledge_callback(FUNC(mie_device::irq_callback)); +} mie_jvs_device::mie_jvs_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : jvs_host(mconfig, MIE_JVS, tag, owner, clock) @@ -79,24 +80,16 @@ mie_jvs_device::mie_jvs_device(const machine_config &mconfig, const char *tag, d mie_device::mie_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : maple_device(mconfig, MIE, tag, owner, clock) + , cpu(*this, "mie") + , jvs(*this, finder_base::DUMMY_TAG) + , gpio_port(*this, {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG}) { - memset(gpio_name, 0, sizeof(gpio_name)); - jvs_name = nullptr; - cpu = nullptr; - jvs = nullptr; } void mie_device::device_start() { maple_device::device_start(); - cpu = subdevice("mie"); timer = timer_alloc(0); - jvs = machine().device(jvs_name); - - for (int i = 0; i < ARRAY_LENGTH(gpio_name); i++) - { - gpio_port[i] = gpio_name[i] ? ioport(gpio_name[i]) : nullptr; - } save_item(NAME(gpiodir)); save_item(NAME(gpio_val)); diff --git a/src/mame/machine/mie.h b/src/mame/machine/mie.h index bb27602cd06..9d7df4d4dd2 100644 --- a/src/mame/machine/mie.h +++ b/src/mame/machine/mie.h @@ -11,18 +11,6 @@ #include "machine/eepromser.h" #include "machine/jvshost.h" -#define MCFG_MIE_ADD(_tag, _clock, _host_tag, _host_port, g0, g1, g2, g3, g4, g5, g6, g7) \ - MCFG_MAPLE_DEVICE_ADD(_tag "_maple", MIE, _clock, _host_tag, _host_port) \ - downcast(*device).set_gpio_name(0, g0); \ - downcast(*device).set_gpio_name(1, g1); \ - downcast(*device).set_gpio_name(2, g2); \ - downcast(*device).set_gpio_name(3, g3); \ - downcast(*device).set_gpio_name(4, g4); \ - downcast(*device).set_gpio_name(5, g5); \ - downcast(*device).set_gpio_name(6, g6); \ - downcast(*device).set_gpio_name(7, g7); \ - downcast(*device).set_jvs_name(_tag); \ - MCFG_DEVICE_ADD(_tag, MIE_JVS, _clock) class mie_jvs_device; @@ -31,10 +19,19 @@ class mie_jvs_device; class mie_device : public maple_device { public: + template + mie_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&host_tag, int host_port, U &&jvs_tag) + : mie_device(mconfig, tag, owner, clock) + { + host.set_tag(std::forward(host_tag)); + set_host_port(host_port); + jvs.set_tag(std::forward(jvs_tag)); + } + mie_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void set_gpio_name(int entry, const char *name) { gpio_name[entry] = name; } - void set_jvs_name(const char *name) { jvs_name = name; } + template + void set_gpio_name(T &&gpio_port_tag) { gpio_port[Which].set_tag(std::forward(gpio_port_tag)); } DECLARE_READ8_MEMBER(control_r); DECLARE_WRITE8_MEMBER(control_w); @@ -74,9 +71,6 @@ public: void mie_map(address_map &map); void mie_port(address_map &map); protected: - const char *gpio_name[8]; - const char *jvs_name; - // device-level overrides virtual void device_start() override; virtual void device_reset() override; @@ -103,10 +97,10 @@ private: }; // internal state - z80_device *cpu; + required_device cpu; emu_timer *timer; - mie_jvs_device *jvs; - ioport_port *gpio_port[8]; + required_device jvs; + optional_ioport_array<8> gpio_port; uint32_t tbuf[TBUF_SIZE]; uint32_t control, lreg, jvs_rpos; diff --git a/src/mame/machine/segacrp2_device.cpp b/src/mame/machine/segacrp2_device.cpp index 6e8f09c6a16..b07f735445d 100644 --- a/src/mame/machine/segacrp2_device.cpp +++ b/src/mame/machine/segacrp2_device.cpp @@ -97,7 +97,8 @@ DEFINE_DEVICE_TYPE(SEGA_317_0007, sega_317_0007_device, "sega_317_0007", "Sega 3 -segacrp2_z80_device::segacrp2_z80_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : z80_device(mconfig, type, tag, owner, clock) {} +segacrp2_z80_device::segacrp2_z80_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : z80_device(mconfig, type, tag, owner, clock) +, m_decrypted(*this, finder_base::DUMMY_TAG) {} void segacrp2_z80_device::device_start() { z80_device::device_start(); decrypt(); } void segacrp2_z80_device::device_reset() { z80_device::device_reset(); } void segacrp2_z80_device::decrypt() { } @@ -157,7 +158,7 @@ void sega_315_5177_device::decrypt() 20,20,20,20,20, 21,21, }; - decode(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), xor_table, swap_table); + decode(memregion(tag())->base(), m_decrypted, xor_table, swap_table); } @@ -200,7 +201,7 @@ void sega_315_5162_device::decrypt() 12, }; - decode(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), xor_table, swap_table); + decode(memregion(tag())->base(), m_decrypted, xor_table, swap_table); } @@ -249,7 +250,7 @@ void sega_315_5178_device::decrypt() 14, 8,10,12,14, 8,10, }; - decode(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), xor_table, swap_table); + decode(memregion(tag())->base(), m_decrypted, xor_table, swap_table); } @@ -293,7 +294,7 @@ void sega_315_5179_device::decrypt() 7, }; - decode(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), xor_table, swap_table); + decode(memregion(tag())->base(), m_decrypted, xor_table, swap_table); } @@ -339,7 +340,7 @@ static void sega_decode_317(uint8_t *rom, uint8_t *decrypted, int shift) sega_317_0004_device::sega_317_0004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : segacrp2_z80_device(mconfig, SEGA_317_0004, tag, owner, clock) {} void sega_317_0004_device::decrypt() { // 317-0004 - sega_decode_317(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), 0); + sega_decode_317(memregion(tag())->base(), m_decrypted, 0); } @@ -347,18 +348,18 @@ void sega_317_0004_device::decrypt() sega_317_0005_device::sega_317_0005_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : segacrp2_z80_device(mconfig, SEGA_317_0005, tag, owner, clock) {} void sega_317_0005_device::decrypt() { // 317-0005 - sega_decode_317(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), 1); + sega_decode_317(memregion(tag())->base(), m_decrypted, 1); } sega_317_0006_device::sega_317_0006_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : segacrp2_z80_device(mconfig, SEGA_317_0006, tag, owner, clock) {} void sega_317_0006_device::decrypt() { // 317-0006 - sega_decode_317(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), 2); + sega_decode_317(memregion(tag())->base(), m_decrypted, 2); } sega_317_0007_device::sega_317_0007_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : segacrp2_z80_device(mconfig, SEGA_317_0007, tag, owner, clock) {} void sega_317_0007_device::decrypt() { // 317-0006 - sega_decode_317(memregion(tag())->base(), (uint8_t*)memshare(m_decrypted_tag)->ptr(), 3); + sega_decode_317(memregion(tag())->base(), m_decrypted, 3); } diff --git a/src/mame/machine/segacrp2_device.h b/src/mame/machine/segacrp2_device.h index 2b8a8039990..b1035f45182 100644 --- a/src/mame/machine/segacrp2_device.h +++ b/src/mame/machine/segacrp2_device.h @@ -8,22 +8,20 @@ #include "cpu/z80/z80.h" - -#define MCFG_SEGAZ80_SET_DECRYPTED_TAG(_tag) \ - downcast(*device).set_decrypted_tag(_tag); - // base class class segacrp2_z80_device : public z80_device { public: - void set_decrypted_tag(const char* decrypted_tag) { m_decrypted_tag = decrypted_tag; } - const char* m_decrypted_tag; + template void set_decrypted_tag(T &&decrypted_tag) { m_decrypted.set_tag(std::forward(decrypted_tag)); } + protected: segacrp2_z80_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); virtual void device_start() override; virtual void device_reset() override; virtual void decrypt(); + + required_shared_ptr m_decrypted; }; -- cgit v1.2.3