From df98fc2024e53ed5f7a14d2aacedc2e4d6f67f4a Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 17 Jun 2018 01:05:47 -0400 Subject: b2m: Replace machine().device with finder array (nw) --- src/mame/includes/b2m.h | 3 +++ src/mame/machine/b2m.cpp | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mame/includes/b2m.h b/src/mame/includes/b2m.h index 008f3ed6b4e..5856ed7c3a5 100644 --- a/src/mame/includes/b2m.h +++ b/src/mame/includes/b2m.h @@ -11,6 +11,7 @@ #pragma once +#include "imagedev/floppy.h" #include "machine/i8255.h" #include "machine/pic8259.h" #include "machine/pit8253.h" @@ -31,6 +32,7 @@ public: , m_ram(*this, RAM_TAG) , m_palette(*this, "palette") , m_fdc(*this, "fd1793") + , m_fd(*this, "fd%u", 0U) , m_pic(*this, "pic8259") { } @@ -91,6 +93,7 @@ protected: /* devices */ optional_device m_fdc; + optional_device_array m_fd; optional_device m_pic; }; diff --git a/src/mame/machine/b2m.cpp b/src/mame/machine/b2m.cpp index 86d0b5dd5a1..ba39ecc3f06 100644 --- a/src/mame/machine/b2m.cpp +++ b/src/mame/machine/b2m.cpp @@ -17,7 +17,6 @@ #include "machine/i8251.h" #include "includes/b2m.h" #include "machine/ram.h" -#include "imagedev/flopdrv.h" READ8_MEMBER(b2m_state::b2m_keyboard_r) { @@ -182,13 +181,12 @@ WRITE8_MEMBER(b2m_state::b2m_ext_8255_portc_w) uint8_t drive = ((data >> 1) & 1) ^ 1; uint8_t side = (data & 1) ^ 1; - static const char *names[] = { "fd0", "fd1"}; floppy_image_device *floppy = nullptr; - floppy_connector *con = machine().device(names[drive]); - if(con) - floppy = con->get_device(); + if (m_fd[drive].found()) + floppy = m_fd[drive]->get_device(); - floppy->mon_w(0); + if (floppy != nullptr) + floppy->mon_w(0); m_fdc->set_floppy(floppy); if (m_b2m_drive!=drive) { m_b2m_drive = drive; @@ -196,7 +194,8 @@ WRITE8_MEMBER(b2m_state::b2m_ext_8255_portc_w) if (m_b2m_side!=side) { m_b2m_side = side; - floppy->ss_w(side); + if (floppy != nullptr) + floppy->ss_w(side); } /* When bit 5 is set CPU is in HALT state and stay there until -- cgit v1.2.3