mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
oricext.cpp, microdisc.cpp: Use device finders
This commit is contained in:
parent
e6d3720985
commit
3d49ff6d45
@ -30,7 +30,9 @@ void oric_microdisc_device::map(address_map &map)
|
||||
oric_microdisc_device::oric_microdisc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, ORIC_MICRODISC, tag, owner, clock),
|
||||
device_oricext_interface(mconfig, *this),
|
||||
fdc(*this, "fdc"), microdisc_rom(nullptr), port_314(0), intrq_state(false), drq_state(false), hld_state(false)
|
||||
fdc(*this, "fdc"), microdisc_rom(nullptr),
|
||||
floppies(*this, "fdc:%u", 0U),
|
||||
port_314(0), intrq_state(false), drq_state(false), hld_state(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -43,11 +45,6 @@ void oric_microdisc_device::device_start()
|
||||
microdisc_rom = device().machine().root_device().memregion(this->subtag("microdisc").c_str())->base();
|
||||
cpu->space(AS_PROGRAM).install_device(0x0000, 0xffff, *this, &oric_microdisc_device::map);
|
||||
|
||||
for(int i=0; i<4; i++) {
|
||||
char name[32];
|
||||
sprintf(name, "fdc:%d", i);
|
||||
floppies[i] = subdevice<floppy_connector>(name)->get_device();
|
||||
}
|
||||
intrq_state = drq_state = hld_state = false;
|
||||
}
|
||||
|
||||
@ -56,7 +53,7 @@ void oric_microdisc_device::device_reset()
|
||||
port_314 = 0x00;
|
||||
irq_w(false);
|
||||
remap();
|
||||
fdc->set_floppy(floppies[0]);
|
||||
fdc->set_floppy(floppies[0]->get_device());
|
||||
|
||||
// The bootstrap checksums part of the high ram and if the sum is
|
||||
// 0 it goes wrong.
|
||||
@ -112,7 +109,7 @@ void oric_microdisc_device::port_314_w(uint8_t data)
|
||||
{
|
||||
port_314 = data;
|
||||
remap();
|
||||
floppy_image_device *floppy = floppies[(port_314 >> 5) & 3];
|
||||
floppy_image_device *floppy = floppies[(port_314 >> 5) & 3]->get_device();
|
||||
fdc->set_floppy(floppy);
|
||||
fdc->dden_w(port_314 & P_DDEN);
|
||||
if(floppy) {
|
||||
@ -147,5 +144,7 @@ WRITE_LINE_MEMBER(oric_microdisc_device::fdc_hld_w)
|
||||
{
|
||||
logerror("hld %d\n", state);
|
||||
hld_state = state;
|
||||
floppies[(port_314 >> 5) & 3]->mon_w(!hld_state);
|
||||
floppy_image_device *floppy = floppies[(port_314 >> 5) & 3]->get_device();
|
||||
if(floppy)
|
||||
floppy->mon_w(!hld_state);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ protected:
|
||||
required_device<fd1793_device> fdc;
|
||||
|
||||
uint8_t *microdisc_rom;
|
||||
floppy_image_device *floppies[4];
|
||||
required_device_array<floppy_connector, 4> floppies;
|
||||
uint8_t port_314;
|
||||
bool intrq_state, drq_state, hld_state;
|
||||
|
||||
|
@ -11,7 +11,7 @@ oricext_connector::oricext_connector(const machine_config &mconfig, const char *
|
||||
device_t(mconfig, ORICEXT_CONNECTOR, tag, owner, clock),
|
||||
device_single_card_slot_interface<device_oricext_interface>(mconfig, *this),
|
||||
irq_handler(*this),
|
||||
cputag(nullptr)
|
||||
cpu(*this, finder_base::DUMMY_TAG)
|
||||
{
|
||||
}
|
||||
|
||||
@ -19,11 +19,6 @@ oricext_connector::~oricext_connector()
|
||||
{
|
||||
}
|
||||
|
||||
void oricext_connector::set_cputag(const char *tag)
|
||||
{
|
||||
cputag = tag;
|
||||
}
|
||||
|
||||
void oricext_connector::device_start()
|
||||
{
|
||||
irq_handler.resolve_safe();
|
||||
@ -34,16 +29,8 @@ void oricext_connector::irq_w(int state)
|
||||
irq_handler(state);
|
||||
}
|
||||
|
||||
void oricext_connector::device_config_complete()
|
||||
{
|
||||
device_oricext_interface *dev = get_card_device();
|
||||
if(dev)
|
||||
dev->set_cputag(cputag);
|
||||
}
|
||||
|
||||
device_oricext_interface::device_oricext_interface(const machine_config &mconfig, device_t &device) :
|
||||
device_interface(device, "oricext"),
|
||||
cputag(nullptr),
|
||||
cpu(nullptr),
|
||||
connector(nullptr),
|
||||
bank_c000_r(nullptr),
|
||||
@ -57,22 +44,17 @@ device_oricext_interface::device_oricext_interface(const machine_config &mconfig
|
||||
{
|
||||
}
|
||||
|
||||
void device_oricext_interface::set_cputag(const char *tag)
|
||||
{
|
||||
cputag = tag;
|
||||
}
|
||||
|
||||
void device_oricext_interface::interface_pre_start()
|
||||
{
|
||||
cpu = device().machine().device<m6502_device>(cputag);
|
||||
connector = downcast<oricext_connector *>(device().owner());
|
||||
cpu = connector->cpu.target();
|
||||
bank_c000_r = device().membank(":bank_c000_r");
|
||||
bank_e000_r = device().membank(":bank_e000_r");
|
||||
bank_f800_r = device().membank(":bank_f800_r");
|
||||
bank_c000_w = device().membank(":bank_c000_w");
|
||||
bank_e000_w = device().membank(":bank_e000_w");
|
||||
bank_f800_w = device().membank(":bank_f800_w");
|
||||
rom = (uint8_t *)device().machine().root_device().memregion(cputag)->base();
|
||||
rom = (uint8_t *)cpu->memregion(DEVICE_SELF)->base();
|
||||
ram = (uint8_t *)device().memshare(":ram")->ptr();
|
||||
|
||||
memset(junk_read, 0xff, sizeof(junk_read));
|
||||
|
@ -17,37 +17,37 @@ class device_oricext_interface;
|
||||
|
||||
class oricext_connector: public device_t, public device_single_card_slot_interface<device_oricext_interface>
|
||||
{
|
||||
friend class device_oricext_interface;
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
oricext_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, const char *cputag)
|
||||
template <typename T, typename U>
|
||||
oricext_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, U &&cputag)
|
||||
: oricext_connector(mconfig, tag, owner, (uint32_t)0)
|
||||
{
|
||||
option_reset();
|
||||
opts(*this);
|
||||
set_default_option(dflt);
|
||||
set_fixed(false);
|
||||
set_cputag(cputag);
|
||||
set_cputag(std::forward<U>(cputag));
|
||||
}
|
||||
|
||||
oricext_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
virtual ~oricext_connector();
|
||||
|
||||
void set_cputag(const char *tag);
|
||||
template <typename T> void set_cputag(T &&tag) { cpu.set_tag(std::forward<T>(tag)); }
|
||||
auto irq_callback() { return irq_handler.bind(); }
|
||||
void irq_w(int state);
|
||||
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_config_complete() override;
|
||||
|
||||
devcb_write_line irq_handler;
|
||||
const char *cputag;
|
||||
required_device<m6502_device> cpu;
|
||||
};
|
||||
|
||||
class device_oricext_interface : public device_interface
|
||||
{
|
||||
public:
|
||||
void set_cputag(const char *tag);
|
||||
DECLARE_WRITE_LINE_MEMBER(irq_w);
|
||||
|
||||
protected:
|
||||
@ -55,7 +55,6 @@ protected:
|
||||
|
||||
virtual void interface_pre_start() override;
|
||||
|
||||
const char *cputag;
|
||||
m6502_device *cpu;
|
||||
oricext_connector *connector;
|
||||
memory_bank *bank_c000_r, *bank_e000_r, *bank_f800_r, *bank_c000_w, *bank_e000_w, *bank_f800_w;
|
||||
|
Loading…
Reference in New Issue
Block a user