(MESS) apple2 updates: [R. Belmont]

- Provide centralized DMA mechanism for slot cards
- Fixed 0.156 regressions for Z80 SoftCard, The Mill 6809, and Mountain Computer Music System
- Provide debugger protection for slot-based foreign CPUs executing from Apple II DMA
This commit is contained in:
arbee 2015-01-31 22:28:22 -05:00
parent 0d5783fd85
commit 5dab7eb95c
8 changed files with 130 additions and 108 deletions

View File

@ -160,6 +160,7 @@ a2bus_device::a2bus_device(const machine_config &mconfig, device_type type, cons
void a2bus_device::device_start()
{
m_maincpu = machine().device<cpu_device>(m_cputag);
m_maincpu_space = &machine().device<cpu_device>(m_cputag)->space(AS_PROGRAM);
// resolve callbacks
m_out_irq_cb.resolve_safe();
@ -246,6 +247,30 @@ void a2bus_device::set_maincpu_halt(int state)
m_maincpu->set_input_line(INPUT_LINE_HALT, state);
}
UINT8 a2bus_device::dma_r(address_space &space, UINT16 offset)
{
m_maincpu_space->set_debugger_access(space.debugger_access());
return m_maincpu_space->read_byte(offset);
}
void a2bus_device::dma_w(address_space &space, UINT16 offset, UINT8 data)
{
m_maincpu_space->set_debugger_access(space.debugger_access());
m_maincpu_space->write_byte(offset, data);
}
UINT8 a2bus_device::dma_nospace_r(UINT16 offset)
{
return m_maincpu_space->read_byte(offset);
}
void a2bus_device::dma_nospace_w(UINT16 offset, UINT8 data)
{
m_maincpu_space->write_byte(offset, data);
}
void a2bus_device::recalc_inh(int slot)
{
m_out_inh_cb(ASSERT_LINE);

View File

@ -106,6 +106,10 @@ public:
void set_nmi_line(int state, int slot);
void set_maincpu_halt(int state);
void recalc_inh(int slot);
UINT8 dma_r(address_space &space, UINT16 offset);
void dma_w(address_space &space, UINT16 offset, UINT8 data);
UINT8 dma_nospace_r(UINT16 offset);
void dma_nospace_w(UINT16 offset, UINT8 data);
DECLARE_WRITE_LINE_MEMBER( irq_w );
DECLARE_WRITE_LINE_MEMBER( nmi_w );
@ -117,6 +121,7 @@ protected:
// internal state
cpu_device *m_maincpu;
address_space *m_maincpu_space;
devcb_write_line m_out_irq_cb;
devcb_write_line m_out_nmi_cb;
@ -144,12 +149,12 @@ public:
device_a2bus_card_interface(const machine_config &mconfig, device_t &device);
virtual ~device_a2bus_card_interface();
virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { printf("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL
virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to C0n%x\n", data, offset); }
virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { logerror("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL
virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to C0n%x\n", data, offset); }
virtual UINT8 read_cnxx(address_space &space, UINT8 offset) { return 0; } // CnXX - /IOSEL
virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to Cn%02x\n", data, offset); }
virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to Cn%02x\n", data, offset); }
virtual UINT8 read_c800(address_space &space, UINT16 offset) { return 0; } // C800 - /IOSTB
virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { printf("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); }
virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); }
virtual bool take_c800() { return true; } // override and return false if your card doesn't take over the c800 space
virtual UINT8 read_inh_rom(address_space &space, UINT16 offset) { return 0; }
virtual void write_inh_rom(address_space &space, UINT16 offset, UINT8 data) { }
@ -171,6 +176,15 @@ public:
void recalc_slot_inh() { m_a2bus->recalc_inh(m_slot); }
void set_maincpu_halt(int state) { m_a2bus->set_maincpu_halt(state); }
// pass through the original address space if any for debugger protection
// when debugging e.g. coprocessor cards (Z80 SoftCard etc).
UINT8 slot_dma_read(address_space &space, UINT16 offset) { return m_a2bus->dma_r(space, offset); }
void slot_dma_write(address_space &space, UINT16 offset, UINT8 data) { m_a2bus->dma_w(space, offset, data); }
// these versions forego that protection for when the DMA isn't coming from a debuggable CPU device
UINT8 slot_dma_read_no_space(UINT16 offset) { return m_a2bus->dma_nospace_r(offset); }
void slot_dma_write_no_space(UINT16 offset, UINT8 data) { m_a2bus->dma_nospace_w(offset, data); }
// inline configuration
static void static_set_a2bus_tag(device_t &device, const char *tag, const char *slottag);
public:

View File

@ -94,6 +94,7 @@ void a2bus_mcms1_device::device_start()
void a2bus_mcms1_device::device_reset()
{
m_mcms->set_bus_device(this);
}
// read once at c0n0 to disable 125 Hz IRQs
@ -290,7 +291,7 @@ void mcms_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
wptr = (m_table[v]<<8) | (m_acc[v]>>8);
m_rand = (m_acc[v]>>8) & 0x1f;
sample = (m_6502space->read_byte(wptr) ^ 0x80);
sample = (m_pBusDevice->slot_dma_read_no_space(wptr) ^ 0x80);
if (v & 1)
{
mixL += sample * m_vols[v];
@ -355,9 +356,6 @@ WRITE8_MEMBER(mcms_device::voiceregs_w)
WRITE8_MEMBER(mcms_device::control_w)
{
// keep the space (TODO: we need to define a formal DMA mechanism from machine/apple2 out to the slots)
m_6502space = &space;
m_stream->update();
switch (offset)

View File

@ -20,6 +20,8 @@
// TYPE DEFINITIONS
//**************************************************************************
class a2bus_mcms1_device;
class mcms_device : public device_t, public device_sound_interface
{
public:
@ -30,6 +32,8 @@ public:
DECLARE_WRITE8_MEMBER(control_w);
UINT8 get_pen_rand(void) { m_stream->update(); return m_rand; }
void set_bus_device(a2bus_mcms1_device *pDev) { m_pBusDevice = pDev; }
template<class _Object> static devcb_base &set_irq_cb(device_t &device, _Object wr) { return downcast<mcms_device &>(device).m_write_irq.set_callback(wr); }
devcb_write_line m_write_irq;
@ -43,8 +47,8 @@ protected:
private:
sound_stream *m_stream;
address_space *m_6502space;
emu_timer *m_timer, *m_clrtimer;
a2bus_mcms1_device *m_pBusDevice;
bool m_enabled;
UINT8 m_vols[16];
UINT8 m_table[16];

View File

@ -52,16 +52,14 @@ machine_config_constructor a2bus_softcard_device::device_mconfig_additions() con
a2bus_softcard_device::a2bus_softcard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_a2bus_card_interface(mconfig, *this),
m_z80(*this, Z80_TAG),
m_6502space(NULL)
m_z80(*this, Z80_TAG)
{
}
a2bus_softcard_device::a2bus_softcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, A2BUS_SOFTCARD, "Microsoft SoftCard", tag, owner, clock, "a2softcard", __FILE__),
device_a2bus_card_interface(mconfig, *this),
m_z80(*this, Z80_TAG),
m_6502space(NULL)
m_z80(*this, Z80_TAG)
{
}
@ -82,7 +80,6 @@ void a2bus_softcard_device::device_reset()
{
m_bEnabled = false;
m_6502space = NULL;
m_FirstZ80Boot = true;
m_z80->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
}
@ -91,9 +88,6 @@ void a2bus_softcard_device::write_cnxx(address_space &space, UINT8 offset, UINT8
{
if (!m_bEnabled)
{
// steal the 6502's address space
m_6502space = &space;
m_z80->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
set_maincpu_halt(ASSERT_LINE);
@ -115,31 +109,31 @@ void a2bus_softcard_device::write_cnxx(address_space &space, UINT8 offset, UINT8
READ8_MEMBER( a2bus_softcard_device::dma_r )
{
if (m_6502space)
if (m_bEnabled)
{
if (offset <= 0xafff)
{
return m_6502space->read_byte(offset+0x1000);
return slot_dma_read(space, offset+0x1000);
}
else if (offset <= 0xbfff) // LC bank 2 d000-dfff
{
return m_6502space->read_byte((offset&0xfff) + 0xd000);
return slot_dma_read(space, (offset&0xfff) + 0xd000);
}
else if (offset <= 0xcfff) // LC e000-efff
{
return m_6502space->read_byte((offset&0xfff) + 0xe000);
return slot_dma_read(space, (offset&0xfff) + 0xe000);
}
else if (offset <= 0xdfff) // LC f000-ffff (or ROM?)
{
return m_6502space->read_byte((offset&0xfff) + 0xf000);
return slot_dma_read(space, (offset&0xfff) + 0xf000);
}
else if (offset <= 0xefff) // I/O space c000-cfff
{
return m_6502space->read_byte((offset&0xfff) + 0xc000);
return slot_dma_read(space, (offset&0xfff) + 0xc000);
}
else // zero page
{
return m_6502space->read_byte(offset&0xfff);
return slot_dma_read(space, offset&0xfff);
}
}
@ -153,31 +147,31 @@ READ8_MEMBER( a2bus_softcard_device::dma_r )
WRITE8_MEMBER( a2bus_softcard_device::dma_w )
{
if (m_6502space)
if (m_bEnabled)
{
if (offset <= 0xafff)
{
m_6502space->write_byte(offset+0x1000, data);
slot_dma_write(space, offset+0x1000, data);
}
else if (offset <= 0xbfff) // LC bank 2 d000-dfff
{
m_6502space->write_byte((offset&0xfff) + 0xd000, data);
slot_dma_write(space, (offset&0xfff) + 0xd000, data);
}
else if (offset <= 0xcfff) // LC e000-efff
{
m_6502space->write_byte((offset&0xfff) + 0xe000, data);
slot_dma_write(space, (offset&0xfff) + 0xe000, data);
}
else if (offset <= 0xdfff) // LC f000-ffff (or ROM?)
{
m_6502space->write_byte((offset&0xfff) + 0xf000, data);
slot_dma_write(space, (offset&0xfff) + 0xf000, data);
}
else if (offset <= 0xefff) // I/O space c000-cfff
{
m_6502space->write_byte((offset&0xfff) + 0xc000, data);
slot_dma_write(space, (offset&0xfff) + 0xc000, data);
}
else // zero page
{
m_6502space->write_byte(offset&0xfff, data);
slot_dma_write(space, offset&0xfff, data);
}
}
}

View File

@ -44,7 +44,6 @@ protected:
private:
bool m_bEnabled;
bool m_FirstZ80Boot;
address_space *m_6502space;
};
// device type definition

View File

@ -71,16 +71,14 @@ machine_config_constructor a2bus_themill_device::device_mconfig_additions() cons
a2bus_themill_device::a2bus_themill_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_a2bus_card_interface(mconfig, *this),
m_6809(*this, M6809_TAG),
m_6502space(NULL)
m_6809(*this, M6809_TAG)
{
}
a2bus_themill_device::a2bus_themill_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, A2BUS_THEMILL, "Stellation Two The Mill", tag, owner, clock, "a2themill", __FILE__),
device_a2bus_card_interface(mconfig, *this),
m_6809(*this, M6809_TAG),
m_6502space(NULL)
m_6809(*this, M6809_TAG)
{
}
@ -102,7 +100,6 @@ void a2bus_themill_device::device_start()
void a2bus_themill_device::device_reset()
{
m_bEnabled = false;
m_6502space = NULL;
m_flipAddrSpace = false;
m_6809Mode = false;
m_status = 0xc0; // OS9 loader relies on this
@ -135,8 +132,6 @@ void a2bus_themill_device::write_c0nx(address_space &space, UINT8 offset, UINT8
case 2: // 6809 reset
if (data & 0x80)
{
// steal the 6502's address space
m_6502space = &space;
m_6809->reset();
m_6809->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
@ -241,45 +236,42 @@ void a2bus_themill_device::write_c0nx(address_space &space, UINT8 offset, UINT8
READ8_MEMBER( a2bus_themill_device::dma_r )
{
if (m_6502space)
if (m_6809Mode)
{
if (m_6809Mode)
if (offset <= 0xafff)
{
if (offset <= 0xafff)
{
return m_6502space->read_byte(offset+0x1000);
}
else if (offset <= 0xbfff)
{
return m_6502space->read_byte((offset&0xfff) + 0xd000);
}
else if (offset <= 0xcfff)
{
return m_6502space->read_byte((offset&0xfff) + 0xe000);
}
else if (offset <= 0xdfff)
{
return m_6502space->read_byte((offset&0xfff) + 0xf000);
}
else if (offset <= 0xefff)
{
return m_6502space->read_byte((offset&0xfff) + 0xc000);
}
else // 6809 Fxxx -> 6502 ZP
{
return m_6502space->read_byte(offset&0xfff);
}
return slot_dma_read(space, offset+0x1000);
}
else if (offset <= 0xbfff)
{
return slot_dma_read(space, (offset&0xfff) + 0xd000);
}
else if (offset <= 0xcfff)
{
return slot_dma_read(space, (offset&0xfff) + 0xe000);
}
else if (offset <= 0xdfff)
{
return slot_dma_read(space, (offset&0xfff) + 0xf000);
}
else if (offset <= 0xefff)
{
return slot_dma_read(space, (offset&0xfff) + 0xc000);
}
else // 6809 Fxxx -> 6502 ZP
{
return slot_dma_read(space, offset&0xfff);
}
}
else
{
if (m_flipAddrSpace)
{
return slot_dma_read(space, offset^0x8000);
}
else
{
if (m_flipAddrSpace)
{
return m_6502space->read_byte(offset^0x8000);
}
else
{
return m_6502space->read_byte(offset);
}
return slot_dma_read(space, offset);
}
}
@ -293,45 +285,42 @@ READ8_MEMBER( a2bus_themill_device::dma_r )
WRITE8_MEMBER( a2bus_themill_device::dma_w )
{
if (m_6502space)
if (m_6809Mode)
{
if (m_6809Mode)
if (offset <= 0xafff)
{
if (offset <= 0xafff)
{
m_6502space->write_byte(offset+0x1000, data);
}
else if (offset <= 0xbfff)
{
m_6502space->write_byte((offset&0xfff) + 0xd000, data);
}
else if (offset <= 0xcfff)
{
m_6502space->write_byte((offset&0xfff) + 0xe000, data);
}
else if (offset <= 0xdfff)
{
m_6502space->write_byte((offset&0xfff) + 0xf000, data);
}
else if (offset <= 0xefff)
{
m_6502space->write_byte((offset&0xfff) + 0xc000, data);
}
else // 6809 Fxxx -> 6502 ZP
{
m_6502space->write_byte(offset&0xfff, data);
}
slot_dma_write(space, offset+0x1000, data);
}
else if (offset <= 0xbfff)
{
slot_dma_write(space, (offset&0xfff) + 0xd000, data);
}
else if (offset <= 0xcfff)
{
slot_dma_write(space, (offset&0xfff) + 0xe000, data);
}
else if (offset <= 0xdfff)
{
slot_dma_write(space, (offset&0xfff) + 0xf000, data);
}
else if (offset <= 0xefff)
{
slot_dma_write(space, (offset&0xfff) + 0xc000, data);
}
else // 6809 Fxxx -> 6502 ZP
{
slot_dma_write(space, offset&0xfff, data);
}
}
else
{
if (m_flipAddrSpace)
{
slot_dma_write(space, offset^0x8000, data);
}
else
{
if (m_flipAddrSpace)
{
m_6502space->write_byte(offset^0x8000, data);
}
else
{
m_6502space->write_byte(offset, data);
}
slot_dma_write(space, offset, data);
}
}
}

View File

@ -46,7 +46,6 @@ private:
bool m_bEnabled;
bool m_flipAddrSpace;
bool m_6809Mode;
address_space *m_6502space;
UINT8 m_status;
};