From 2b1d3785bcb693bb43fc86faeb28344bcc65ed80 Mon Sep 17 00:00:00 2001 From: Sergey Svishchev Date: Sun, 4 Mar 2018 20:50:46 +0300 Subject: [PATCH] modernize -- nuke first_screen, ioport() lookups, etc. (nw) --- src/devices/bus/a2bus/agat7langcard.h | 1 - src/devices/bus/a2bus/agat7ports.cpp | 3 +- src/devices/bus/a2bus/agat7ports.h | 3 +- src/devices/bus/a2bus/agat7ram.h | 1 - src/devices/bus/isa/p1_rom.h | 2 +- src/mame/drivers/mc1502.cpp | 37 +++++++++--------------- src/mame/drivers/poisk1.cpp | 41 +++++++++++++++------------ src/mame/drivers/sm7238.cpp | 2 +- src/mame/includes/mc1502.h | 27 ++++++++++-------- 9 files changed, 57 insertions(+), 60 deletions(-) diff --git a/src/devices/bus/a2bus/agat7langcard.h b/src/devices/bus/a2bus/agat7langcard.h index 453c4488a36..e7dae54ebfb 100644 --- a/src/devices/bus/a2bus/agat7langcard.h +++ b/src/devices/bus/a2bus/agat7langcard.h @@ -13,7 +13,6 @@ #pragma once -#include "emu.h" #include "a2bus.h" //************************************************************************** diff --git a/src/devices/bus/a2bus/agat7ports.cpp b/src/devices/bus/a2bus/agat7ports.cpp index 0bf0b6cbba8..8a4976dd40a 100644 --- a/src/devices/bus/a2bus/agat7ports.cpp +++ b/src/devices/bus/a2bus/agat7ports.cpp @@ -80,6 +80,7 @@ ioport_constructor a2bus_agat7_ports_device::device_input_ports() const a2bus_agat7_ports_device::a2bus_agat7_ports_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) , device_a2bus_card_interface(mconfig, *this) + , m_printer_cfg(*this, "PRINTER_CFG") , m_d9(*this, "d9") , m_d10(*this, "d10") , m_centronics(*this, "centronics") @@ -185,7 +186,7 @@ WRITE8_MEMBER(a2bus_agat7_ports_device::write_portb) */ READ8_MEMBER(a2bus_agat7_ports_device::read_portc) { - return (m_centronics_busy << 7) | ioport("PRINTER_CFG")->read(); + return (m_centronics_busy << 7) | m_printer_cfg->read(); } WRITE_LINE_MEMBER(a2bus_agat7_ports_device::write_centronics_busy) diff --git a/src/devices/bus/a2bus/agat7ports.h b/src/devices/bus/a2bus/agat7ports.h index d26913aca46..6b96ee0d783 100644 --- a/src/devices/bus/a2bus/agat7ports.h +++ b/src/devices/bus/a2bus/agat7ports.h @@ -13,7 +13,6 @@ #pragma once -#include "emu.h" #include "a2bus.h" #include "bus/centronics/ctronics.h" @@ -45,6 +44,8 @@ protected: virtual uint8_t read_c0nx(uint8_t offset) override; virtual void write_c0nx(uint8_t offset, uint8_t data) override; + required_ioport m_printer_cfg; + required_device m_d9; required_device m_d10; required_device m_centronics; diff --git a/src/devices/bus/a2bus/agat7ram.h b/src/devices/bus/a2bus/agat7ram.h index 343b197e3e8..6b8529fcb7b 100644 --- a/src/devices/bus/a2bus/agat7ram.h +++ b/src/devices/bus/a2bus/agat7ram.h @@ -13,7 +13,6 @@ #pragma once -#include "emu.h" #include "a2bus.h" //************************************************************************** diff --git a/src/devices/bus/isa/p1_rom.h b/src/devices/bus/isa/p1_rom.h index f91d048a523..d5fd89662d5 100644 --- a/src/devices/bus/isa/p1_rom.h +++ b/src/devices/bus/isa/p1_rom.h @@ -35,7 +35,7 @@ protected: // device type definition -extern const device_type P1_ROM; +DECLARE_DEVICE_TYPE(P1_ROM, p1_rom_device) #endif // MAME_BUS_ISA_P1_ROM_H diff --git a/src/mame/drivers/mc1502.cpp b/src/mame/drivers/mc1502.cpp index 22273754d9b..6940be9ed91 100644 --- a/src/mame/drivers/mc1502.cpp +++ b/src/mame/drivers/mc1502.cpp @@ -49,18 +49,11 @@ TIMER_CALLBACK_MEMBER(mc1502_state::keyb_signal_callback) { uint8_t key = 0; - key |= ioport("Y1")->read(); - key |= ioport("Y2")->read(); - key |= ioport("Y3")->read(); - key |= ioport("Y4")->read(); - key |= ioport("Y5")->read(); - key |= ioport("Y6")->read(); - key |= ioport("Y7")->read(); - key |= ioport("Y8")->read(); - key |= ioport("Y9")->read(); - key |= ioport("Y10")->read(); - key |= ioport("Y11")->read(); - key |= ioport("Y12")->read(); + for (int i = 0; i < 12; i++) + { + key |= m_kbdio[i]->read(); + } + // DBG_LOG(1,"mc1502_k_s_c",("= %02X (%d) %s\n", key, m_kbd.pulsing, // (key || m_kbd.pulsing) ? " will IRQ" : "")); @@ -126,18 +119,14 @@ READ8_MEMBER(mc1502_state::mc1502_kppi_porta_r) { uint8_t key = 0; - if (m_kbd.mask & 0x0001) { key |= ioport("Y1")->read(); } - if (m_kbd.mask & 0x0002) { key |= ioport("Y2")->read(); } - if (m_kbd.mask & 0x0004) { key |= ioport("Y3")->read(); } - if (m_kbd.mask & 0x0008) { key |= ioport("Y4")->read(); } - if (m_kbd.mask & 0x0010) { key |= ioport("Y5")->read(); } - if (m_kbd.mask & 0x0020) { key |= ioport("Y6")->read(); } - if (m_kbd.mask & 0x0040) { key |= ioport("Y7")->read(); } - if (m_kbd.mask & 0x0080) { key |= ioport("Y8")->read(); } - if (m_kbd.mask & 0x0100) { key |= ioport("Y9")->read(); } - if (m_kbd.mask & 0x0200) { key |= ioport("Y10")->read(); } - if (m_kbd.mask & 0x0400) { key |= ioport("Y11")->read(); } - if (m_kbd.mask & 0x0800) { key |= ioport("Y12")->read(); } + for (int i = 0; i < 12; i++) + { + if (BIT(m_kbd.mask, i)) + { + key |= m_kbdio[i]->read(); + } + } + key ^= 0xff; // DBG_LOG(2,"mc1502_kppi_porta_r",("= %02X\n", key)); return key; diff --git a/src/mame/drivers/poisk1.cpp b/src/mame/drivers/poisk1.cpp index 54cdaa63325..70218e46921 100644 --- a/src/mame/drivers/poisk1.cpp +++ b/src/mame/drivers/poisk1.cpp @@ -74,7 +74,9 @@ public: , m_speaker(*this, "speaker") , m_cassette(*this, "cassette") , m_ram(*this, RAM_TAG) + , m_screen(*this, "screen") , m_palette(*this, "palette") + , m_kbdio(*this, "Y%u", 1) { } required_device m_maincpu; @@ -86,8 +88,11 @@ public: required_device m_speaker; required_device m_cassette; required_device m_ram; + required_device m_screen; required_device m_palette; + required_ioport_array<8> m_kbdio; + DECLARE_DRIVER_INIT(poisk1); DECLARE_MACHINE_START(poisk1); DECLARE_MACHINE_RESET(poisk1); @@ -241,9 +246,9 @@ WRITE8_MEMBER(p1_state::p1_ppi2_porta_w) if (BIT((data ^ m_video.color_select_68), 7)) { if (BIT(data, 7)) - machine().first_screen()->set_visible_area(0, 640 - 1, 0, 200 - 1); + m_screen->set_visible_area(0, 640 - 1, 0, 200 - 1); else - machine().first_screen()->set_visible_area(0, 320 - 1, 0, 200 - 1); + m_screen->set_visible_area(0, 320 - 1, 0, 200 - 1); } m_video.color_select_68 = data; set_palette_luts(); @@ -489,14 +494,14 @@ READ8_MEMBER(p1_state::p1_ppi_portb_r) uint16_t key = 0xffff; uint8_t ret = 0; - if (m_kbpoll_mask & 0x01) { key &= ioport("Y1")->read(); } - if (m_kbpoll_mask & 0x02) { key &= ioport("Y2")->read(); } - if (m_kbpoll_mask & 0x04) { key &= ioport("Y3")->read(); } - if (m_kbpoll_mask & 0x08) { key &= ioport("Y4")->read(); } - if (m_kbpoll_mask & 0x10) { key &= ioport("Y5")->read(); } - if (m_kbpoll_mask & 0x20) { key &= ioport("Y6")->read(); } - if (m_kbpoll_mask & 0x40) { key &= ioport("Y7")->read(); } - if (m_kbpoll_mask & 0x80) { key &= ioport("Y8")->read(); } + for (int i = 0; i < 8; i++) + { + if (BIT(m_kbpoll_mask, i)) + { + key &= m_kbdio[i]->read(); + } + } + ret = key & 0xff; // DBG_LOG(1,"p1_ppi_portb_r",("= %02X\n", ret)); return ret; @@ -507,14 +512,14 @@ READ8_MEMBER(p1_state::p1_ppi_portc_r) uint16_t key = 0xffff; uint8_t ret = 0; - if (m_kbpoll_mask & 0x01) { key &= ioport("Y1")->read(); } - if (m_kbpoll_mask & 0x02) { key &= ioport("Y2")->read(); } - if (m_kbpoll_mask & 0x04) { key &= ioport("Y3")->read(); } - if (m_kbpoll_mask & 0x08) { key &= ioport("Y4")->read(); } - if (m_kbpoll_mask & 0x10) { key &= ioport("Y5")->read(); } - if (m_kbpoll_mask & 0x20) { key &= ioport("Y6")->read(); } - if (m_kbpoll_mask & 0x40) { key &= ioport("Y7")->read(); } - if (m_kbpoll_mask & 0x80) { key &= ioport("Y8")->read(); } + for (int i = 0; i < 8; i++) + { + if (BIT(m_kbpoll_mask, i)) + { + key &= m_kbdio[i]->read(); + } + } + ret = (key >> 8) & 0xff; DBG_LOG(2,"p1_ppi_portc_r",("= %02X\n", ret)); return ret; diff --git a/src/mame/drivers/sm7238.cpp b/src/mame/drivers/sm7238.cpp index 3fc4842537e..fea756e2f2e 100644 --- a/src/mame/drivers/sm7238.cpp +++ b/src/mame/drivers/sm7238.cpp @@ -230,7 +230,7 @@ void sm7238_state::recompute_parameters() refresh = HZ_TO_ATTOSECONDS(20.625_MHz_XTAL) * m_video.stride * 10 * KSM_TOTAL_VERT; } - machine().first_screen()->configure(m_video.stride * 10, KSM_TOTAL_VERT, visarea, refresh); + m_screen->configure(m_video.stride * 10, KSM_TOTAL_VERT, visarea, refresh); } uint32_t sm7238_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) diff --git a/src/mame/includes/mc1502.h b/src/mame/includes/mc1502.h index b70cf0aa363..ef07a2148e6 100644 --- a/src/mame/includes/mc1502.h +++ b/src/mame/includes/mc1502.h @@ -28,18 +28,20 @@ class mc1502_state : public driver_device { public: mc1502_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_upd8251(*this, "upd8251"), - m_pic8259(*this, "pic8259"), - m_pit8253(*this, "pit8253"), - m_ppi8255n1(*this, "ppi8255n1"), - m_ppi8255n2(*this, "ppi8255n2"), - m_isabus(*this, "isa"), - m_speaker(*this, "speaker"), - m_cassette(*this, "cassette"), - m_centronics(*this, "centronics"), - m_ram(*this, RAM_TAG) { } + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_upd8251(*this, "upd8251") + , m_pic8259(*this, "pic8259") + , m_pit8253(*this, "pit8253") + , m_ppi8255n1(*this, "ppi8255n1") + , m_ppi8255n2(*this, "ppi8255n2") + , m_isabus(*this, "isa") + , m_speaker(*this, "speaker") + , m_cassette(*this, "cassette") + , m_centronics(*this, "centronics") + , m_ram(*this, RAM_TAG) + , m_kbdio(*this, "Y%u", 1) + { } required_device m_maincpu; required_device m_upd8251; @@ -52,6 +54,7 @@ public: required_device m_cassette; required_device m_centronics; required_device m_ram; + required_ioport_array<12> m_kbdio; DECLARE_DRIVER_INIT(mc1502); DECLARE_MACHINE_START(mc1502);