Using delegates for 68307 (nw)

This commit is contained in:
Miodrag Milanovic 2014-04-22 08:31:08 +00:00
parent ae27a1935b
commit bbd6d13cc8
7 changed files with 117 additions and 122 deletions

View File

@ -66,11 +66,6 @@ m68307cpu_device::m68307cpu_device(const machine_config &mconfig, const char *ta
m68307_scrhigh = 0;
m68307_scrlow = 0;
m68307_currentcs = 0;
m_m68307_porta_r = 0;
m_m68307_porta_w = 0;
m_m68307_portb_r = 0;
m_m68307_portb_w = 0;
}
@ -176,77 +171,77 @@ void m68307cpu_device::init16_m68307(address_space &space)
void m68307_set_port_callbacks(m68307cpu_device *device, m68307_porta_read_callback porta_r, m68307_porta_write_callback porta_w, m68307_portb_read_callback portb_r, m68307_portb_write_callback portb_w)
void m68307cpu_device::set_port_callbacks(m68307_porta_read_delegate porta_r, m68307_porta_write_delegate porta_w, m68307_portb_read_delegate portb_r, m68307_portb_write_delegate portb_w)
{
device->m_m68307_porta_r = porta_r;
device->m_m68307_porta_w = porta_w;
device->m_m68307_portb_r = portb_r;
device->m_m68307_portb_w = portb_w;
m_m68307_porta_r = porta_r;
m_m68307_porta_w = porta_w;
m_m68307_portb_r = portb_r;
m_m68307_portb_w = portb_w;
}
UINT16 m68307_get_cs(m68307cpu_device *device, offs_t address)
UINT16 m68307cpu_device::get_cs(offs_t address)
{
device->m68307_currentcs = m68307_calc_cs(device, address);
m68307_currentcs = m68307_calc_cs(this, address);
return device->m68307_currentcs;
return m68307_currentcs;
}
/* 68307 specifics - MOVE */
void m68307_set_interrupt(device_t *device, int level, int vector)
void m68307cpu_device::set_interrupt(int level, int vector)
{
device->execute().set_input_line_and_vector(level, HOLD_LINE, vector);
set_input_line_and_vector(level, HOLD_LINE, vector);
}
void m68307_timer0_interrupt(m68307cpu_device *cpudev)
void m68307cpu_device::timer0_interrupt()
{
int prioritylevel = (cpudev->m68307SIM->m_picr & 0x7000)>>12;
int vector = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0xa;
m68307_set_interrupt(cpudev, prioritylevel, vector);
int prioritylevel = (m68307SIM->m_picr & 0x7000)>>12;
int vector = (m68307SIM->m_pivr & 0x00f0) | 0xa;
set_interrupt(prioritylevel, vector);
}
void m68307_timer1_interrupt(m68307cpu_device *cpudev)
void m68307cpu_device::timer1_interrupt()
{
int prioritylevel = (cpudev->m68307SIM->m_picr & 0x0700)>>8;
int vector = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0xb;
m68307_set_interrupt(cpudev, prioritylevel, vector);
int prioritylevel = (m68307SIM->m_picr & 0x0700)>>8;
int vector = (m68307SIM->m_pivr & 0x00f0) | 0xb;
set_interrupt(prioritylevel, vector);
}
void m68307_serial_interrupt(m68307cpu_device *cpudev, int vector)
void m68307cpu_device::serial_interrupt(int vector)
{
int prioritylevel = (cpudev->m68307SIM->m_picr & 0x0070)>>4;
m68307_set_interrupt(cpudev, prioritylevel, vector);
int prioritylevel = (m68307SIM->m_picr & 0x0070)>>4;
set_interrupt(prioritylevel, vector);
}
WRITE_LINE_MEMBER(m68307cpu_device::m68307_duart_irq_handler)
{
if (state == ASSERT_LINE)
{
m68307_serial_interrupt(this, m_duart->get_irq_vector());
serial_interrupt(m_duart->get_irq_vector());
}
}
void m68307_mbus_interrupt(m68307cpu_device *cpudev)
void m68307cpu_device::mbus_interrupt()
{
int prioritylevel = (cpudev->m68307SIM->m_picr & 0x0007)>>0;
int vector = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0xd;
m68307_set_interrupt(cpudev, prioritylevel, vector);
int prioritylevel = (m68307SIM->m_picr & 0x0007)>>0;
int vector = (m68307SIM->m_pivr & 0x00f0) | 0xd;
set_interrupt(prioritylevel, vector);
}
void m68307_licr2_interrupt(m68307cpu_device *cpudev)
void m68307cpu_device::licr2_interrupt()
{
int prioritylevel = (cpudev->m68307SIM->m_licr2 & 0x0007)>>0;
int vector = (cpudev->m68307SIM->m_pivr & 0x00f0) | 0x9;
cpudev->m68307SIM->m_licr2 |= 0x8;
int prioritylevel = (m68307SIM->m_licr2 & 0x0007)>>0;
int vector = (m68307SIM->m_pivr & 0x00f0) | 0x9;
m68307SIM->m_licr2 |= 0x8;
m68307_set_interrupt(cpudev, prioritylevel, vector);
set_interrupt(prioritylevel, vector);
}
void m68307cpu_device::device_start()
@ -280,7 +275,7 @@ void m68307cpu_device::device_start()
read_inport.resolve();
write_outport.resolve_safe();
m68307_set_port_callbacks(this, 0,0,0,0);
set_port_callbacks(m68307_porta_read_delegate(),m68307_porta_write_delegate(),m68307_portb_read_delegate(),m68307_portb_write_delegate());
}

View File

@ -14,11 +14,11 @@
#include "machine/mc68681.h"
typedef device_delegate<UINT8 (address_space &space, bool dedicated, UINT8 line_mask)> m68307_porta_read_delegate;
typedef device_delegate<void (address_space &space, bool dedicated, UINT8 data, UINT8 line_mask)> m68307_porta_write_delegate;
typedef device_delegate<UINT16 (address_space &space, bool dedicated, UINT16 line_mask)> m68307_portb_read_delegate;
typedef device_delegate<void (address_space &space, bool dedicated, UINT16 data, UINT16 line_mask)> m68307_portb_write_delegate;
typedef UINT8 (*m68307_porta_read_callback)(address_space &space, bool dedicated, UINT8 line_mask);
typedef void (*m68307_porta_write_callback)(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask);
typedef UINT16 (*m68307_portb_read_callback)(address_space &space, bool dedicated, UINT16 line_mask);
typedef void (*m68307_portb_write_callback)(address_space &space, bool dedicated, UINT16 data, UINT16 line_mask);
/* trampolines so we can specify the 68681 serial configuration when adding the CPU */
#define MCFG_MC68307_SERIAL_A_TX_CALLBACK(_cb) \
@ -92,10 +92,19 @@ public:
/* callbacks for internal ports */
m68307_porta_read_callback m_m68307_porta_r;
m68307_porta_write_callback m_m68307_porta_w;
m68307_portb_read_callback m_m68307_portb_r;
m68307_portb_write_callback m_m68307_portb_w;
void set_port_callbacks(m68307_porta_read_delegate porta_r, m68307_porta_write_delegate porta_w, m68307_portb_read_delegate portb_r, m68307_portb_write_delegate portb_w);
void set_interrupt(int level, int vector);
UINT16 get_cs(offs_t address);
void timer0_interrupt();
void timer1_interrupt();
void serial_interrupt(int vector);
void mbus_interrupt();
void licr2_interrupt();
m68307_porta_read_delegate m_m68307_porta_r;
m68307_porta_write_delegate m_m68307_porta_w;
m68307_portb_read_delegate m_m68307_portb_r;
m68307_portb_write_delegate m_m68307_portb_w;
void init16_m68307(address_space &space);
void init_cpu_m68307(void);
@ -117,12 +126,5 @@ private:
static const device_type M68307 = &device_creator<m68307cpu_device>;
extern void m68307_set_port_callbacks(m68307cpu_device *device, m68307_porta_read_callback porta_r, m68307_porta_write_callback porta_w, m68307_portb_read_callback portb_r, m68307_portb_write_callback portb_w);
extern UINT16 m68307_get_cs(m68307cpu_device *device, offs_t address);
extern void m68307_timer0_interrupt(m68307cpu_device *cpudev);
extern void m68307_timer1_interrupt(m68307cpu_device *cpudev);
extern void m68307_serial_interrupt(m68307cpu_device *cpudev, int vector);
extern void m68307_mbus_interrupt(m68307cpu_device *cpudev);
extern void m68307_licr2_interrupt(m68307cpu_device *cpudev);
#endif

View File

@ -153,7 +153,7 @@ UINT16 m68307_sim::read_padat(m68307cpu_device* m68k, address_space &space, UINT
{
int pc = space.device().safe_pc();
if (m68k->m_m68307_porta_r)
if (!m68k->m_m68307_porta_r.isnull())
{
// for general purpose bits, if configured as 'output' then anything output gets latched
// and anything configured as input is read from the port
@ -180,7 +180,7 @@ void m68307_sim::write_padat(m68307cpu_device* m68k, address_space &space, UINT1
int pc = space.device().safe_pc();
COMBINE_DATA(&m_padat);
if (m68k->m_m68307_porta_w)
if (!m68k->m_m68307_porta_w.isnull())
{
m68k->m_m68307_porta_w(space, false, data, 0xff);
}
@ -204,7 +204,7 @@ UINT16 m68307_sim::read_pbdat(m68307cpu_device* m68k, address_space &space, UINT
{
int pc = space.device().safe_pc();
if (m68k->m_m68307_portb_r)
if (!m68k->m_m68307_portb_r.isnull())
{
// for general purpose bits, if configured as 'output' then anything output gets latched
// and anything configured as input is read from the port
@ -231,7 +231,7 @@ void m68307_sim::write_pbdat(m68307cpu_device* m68k, address_space &space, UINT1
int pc = space.device().safe_pc();
COMBINE_DATA(&m_pbdat);
if (m68k->m_m68307_portb_w)
if (!m68k->m_m68307_portb_w.isnull())
{
m68k->m_m68307_portb_w(space, false, data, mem_mask);
}

View File

@ -105,7 +105,7 @@ static TIMER_CALLBACK( m68307_timer0_callback )
m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[0];
tptr->regs[m68307TIMER_TMR] |= 0x2;
m68307_timer0_interrupt(m68k);
m68k->timer0_interrupt();
tptr->mametimer->adjust(m68k->cycles_to_attotime(20000));
}
@ -116,7 +116,7 @@ static TIMER_CALLBACK( m68307_timer1_callback )
m68307_single_timer* tptr = &m68k->m68307TIMER->singletimer[1];
tptr->regs[m68307TIMER_TMR] |= 0x2;
m68307_timer1_interrupt(m68k);
m68k->timer1_interrupt();
tptr->mametimer->adjust(m68k->cycles_to_attotime(20000));

View File

@ -112,7 +112,7 @@ READ16_MEMBER(sc4_state::sc4_cs1_r)
READ16_MEMBER(sc4_state::sc4_mem_r)
{
int pc = space.device().safe_pc();
int cs = m68307_get_cs(m_maincpu, offset * 2);
int cs = m_maincpu->get_cs(offset * 2);
int base = 0, end = 0, base2 = 0, end2 = 0;
// if (!(debugger_access())) printf("cs is %d\n", cs);
UINT16 retvalue;
@ -233,8 +233,6 @@ READ16_MEMBER(sc4_state::sc4_mem_r)
return 0x0000;
}
static DECLARE_WRITE8_HANDLER( bfm_sc4_reel4_w );
WRITE8_MEMBER(bfm_sc45_state::mux_output_w)
{
int i;
@ -268,7 +266,7 @@ WRITE8_MEMBER(bfm_sc45_state::mux_output2_w)
WRITE16_MEMBER(sc4_state::sc4_mem_w)
{
int pc = space.device().safe_pc();
int cs = m68307_get_cs(m_maincpu, offset * 2);
int cs = m_maincpu->get_cs(offset * 2);
int base = 0, end = 0, base2 = 0, end2 = 0;
switch ( cs )
@ -443,111 +441,101 @@ ADDRESS_MAP_END
void bfm_sc4_reset_serial_vfd(running_machine &machine)
void bfm_sc45_state::bfm_sc4_reset_serial_vfd()
{
bfm_sc45_state *state = machine.driver_data<bfm_sc45_state>();
state->m_vfd0->reset();
state->vfd_old_clock = false;
m_vfd0->reset();
vfd_old_clock = false;
}
void bfm_sc45_write_serial_vfd(running_machine &machine, bool cs, bool clock, bool data)
void bfm_sc45_state::bfm_sc45_write_serial_vfd(bool cs, bool clock, bool data)
{
bfm_sc45_state *state = machine.driver_data<bfm_sc45_state>();
// if we're turned on
if ( cs )
{
if ( !state->vfd_enabled )
if ( !vfd_enabled )
{
bfm_sc4_reset_serial_vfd(machine);
state->vfd_old_clock = clock;
state->vfd_enabled = true;
bfm_sc4_reset_serial_vfd();
vfd_old_clock = clock;
vfd_enabled = true;
}
else
{
// if the clock line changes
if ( clock != state->vfd_old_clock )
if ( clock != vfd_old_clock )
{
if ( !clock )
{
//Should move to the internal serial process when DM01 is device-ified
// m_vfd0->shift_data(!data);
state->vfd_ser_value <<= 1;
if (data) state->vfd_ser_value |= 1;
vfd_ser_value <<= 1;
if (data) vfd_ser_value |= 1;
state->vfd_ser_count++;
if ( state->vfd_ser_count == 8 )
vfd_ser_count++;
if ( vfd_ser_count == 8 )
{
state->vfd_ser_count = 0;
if (machine.device("matrix"))
vfd_ser_count = 0;
if (machine().device("matrix"))
{
state->m_dm01->writedata(state->vfd_ser_value);
m_dm01->writedata(vfd_ser_value);
}
else
{
state->m_vfd0->write_char(state->vfd_ser_value);
m_vfd0->write_char(vfd_ser_value);
}
}
}
state->vfd_old_clock = clock;
vfd_old_clock = clock;
}
}
}
else
{
state->vfd_enabled = false;
vfd_enabled = false;
}
}
void bfm_sc4_68307_porta_w(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask)
void sc4_state::bfm_sc4_68307_porta_w(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask)
{
sc4_state *state = space.machine().driver_data<sc4_state>();
m_reel12_latch = data;
state->m_reel12_latch = data;
if ( stepper_update(0, data&0x0f ) ) m_reel_changed |= 0x01;
if ( stepper_update(1, (data>>4))&0x0f ) m_reel_changed |= 0x02;
if ( stepper_update(0, data&0x0f ) ) state->m_reel_changed |= 0x01;
if ( stepper_update(1, (data>>4))&0x0f ) state->m_reel_changed |= 0x02;
if ( stepper_optic_state(0) ) state->m_optic_pattern |= 0x01;
else state->m_optic_pattern &= ~0x01;
if ( stepper_optic_state(1) ) state->m_optic_pattern |= 0x02;
else state->m_optic_pattern &= ~0x02;
if ( stepper_optic_state(0) ) m_optic_pattern |= 0x01;
else m_optic_pattern &= ~0x01;
if ( stepper_optic_state(1) ) m_optic_pattern |= 0x02;
else m_optic_pattern &= ~0x02;
awp_draw_reel(0);
awp_draw_reel(1);
}
static WRITE8_HANDLER( bfm_sc4_reel3_w )
WRITE8_MEMBER( sc4_state::bfm_sc4_reel3_w )
{
sc4_state *state = space.machine().driver_data<sc4_state>();
m_reel3_latch = data;
state->m_reel3_latch = data;
if ( stepper_update(2, data&0x0f ) ) m_reel_changed |= 0x04;
if ( stepper_update(2, data&0x0f ) ) state->m_reel_changed |= 0x04;
if ( stepper_optic_state(2) ) state->m_optic_pattern |= 0x04;
else state->m_optic_pattern &= ~0x04;
if ( stepper_optic_state(2) ) m_optic_pattern |= 0x04;
else m_optic_pattern &= ~0x04;
awp_draw_reel(2);
}
static WRITE8_HANDLER( bfm_sc4_reel4_w )
WRITE8_MEMBER( sc4_state::bfm_sc4_reel4_w )
{
sc4_state *state = space.machine().driver_data<sc4_state>();
m_reel4_latch = data;
state->m_reel4_latch = data;
if ( stepper_update(3, data&0x0f ) ) m_reel_changed |= 0x08;
if ( stepper_update(3, data&0x0f ) ) state->m_reel_changed |= 0x08;
if ( stepper_optic_state(3) ) state->m_optic_pattern |= 0x08;
else state->m_optic_pattern &= ~0x08;
if ( stepper_optic_state(3) ) m_optic_pattern |= 0x08;
else m_optic_pattern &= ~0x08;
awp_draw_reel(3);
}
void bfm_sc4_68307_portb_w(address_space &space, bool dedicated, UINT16 data, UINT16 line_mask)
void sc4_state::bfm_sc4_68307_portb_w(address_space &space, bool dedicated, UINT16 data, UINT16 line_mask)
{
// if (dedicated == false)
{
@ -556,20 +544,20 @@ void bfm_sc4_68307_portb_w(address_space &space, bool dedicated, UINT16 data, UI
// serial output to the VFD at least..
logerror("%08x bfm_sc4_68307_portb_w %04x %04x\n", pc, data, line_mask);
bfm_sc45_write_serial_vfd(space.machine(), (data & 0x4000)?1:0, (data & 0x1000)?1:0, !(data & 0x2000)?1:0);
bfm_sc45_write_serial_vfd((data & 0x4000)?1:0, (data & 0x1000)?1:0, !(data & 0x2000)?1:0);
bfm_sc4_reel3_w(space, 0, (data&0x0f00)>>8, 0xff);
}
}
UINT8 bfm_sc4_68307_porta_r(address_space &space, bool dedicated, UINT8 line_mask)
UINT8 sc4_state::bfm_sc4_68307_porta_r(address_space &space, bool dedicated, UINT8 line_mask)
{
int pc = space.device().safe_pc();
logerror("%08x bfm_sc4_68307_porta_r\n", pc);
return space.machine().rand();
return machine().rand();
}
UINT16 bfm_sc4_68307_portb_r(address_space &space, bool dedicated, UINT16 line_mask)
UINT16 sc4_state::bfm_sc4_68307_portb_r(address_space &space, bool dedicated, UINT16 line_mask)
{
if (dedicated==false)
{
@ -605,11 +593,11 @@ MACHINE_START_MEMBER(sc4_state,sc4)
m_nvram->set_base(m_mainram, sizeof(m_mainram));
m68307_set_port_callbacks(m_maincpu,
bfm_sc4_68307_porta_r,
bfm_sc4_68307_porta_w,
bfm_sc4_68307_portb_r,
bfm_sc4_68307_portb_w );
m_maincpu->set_port_callbacks(
m68307_porta_read_delegate(FUNC(sc4_state::bfm_sc4_68307_porta_r),this),
m68307_porta_write_delegate(FUNC(sc4_state::bfm_sc4_68307_porta_w),this),
m68307_portb_read_delegate(FUNC(sc4_state::bfm_sc4_68307_portb_r),this),
m68307_portb_write_delegate(FUNC(sc4_state::bfm_sc4_68307_portb_w),this) );
int reels = 6;
m_reels=reels;
@ -635,7 +623,7 @@ WRITE_LINE_MEMBER(sc4_state::bfm_sc4_duart_irq_handler)
logerror("bfm_sc4_duart_irq_handler\n");
if (state == ASSERT_LINE)
{
m68307_licr2_interrupt(m_maincpu);
m_maincpu->licr2_interrupt();
}
}

View File

@ -173,7 +173,7 @@ WRITE8_MEMBER( bfm_sc5_state::sc5_10202F0_w )
switch (offset)
{
case 0x0:
bfm_sc45_write_serial_vfd(machine(), (data &0x4)?1:0, (data &0x1)?1:0, (data&0x2) ? 0:1);
bfm_sc45_write_serial_vfd((data &0x4)?1:0, (data &0x1)?1:0, (data&0x2) ? 0:1);
if (data&0xf8) printf("%s: sc5_10202F0_w %d - %02x\n", machine().describe_context(), offset, data);
break;
case 0x1:

View File

@ -42,7 +42,8 @@ public:
DECLARE_WRITE8_MEMBER(mux_output_w);
DECLARE_WRITE8_MEMBER(mux_output2_w);
void bfm_sc4_reset_serial_vfd();
void bfm_sc45_write_serial_vfd(bool cs, bool clock, bool data);
};
void bfm_sc45_write_serial_vfd(running_machine &machine, bool cs, bool clock, bool data);
@ -533,6 +534,15 @@ public:
DECLARE_MACHINE_RESET(sc4);
DECLARE_WRITE_LINE_MEMBER(bfm_sc4_irqhandler);
void bfm_sc4_68307_porta_w(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask);
DECLARE_WRITE8_MEMBER( bfm_sc4_reel3_w );
DECLARE_WRITE8_MEMBER( bfm_sc4_reel4_w );
void bfm_sc4_68307_portb_w(address_space &space, bool dedicated, UINT16 data, UINT16 line_mask);
UINT8 bfm_sc4_68307_porta_r(address_space &space, bool dedicated, UINT8 line_mask);
UINT16 bfm_sc4_68307_portb_r(address_space &space, bool dedicated, UINT16 line_mask);
protected:
required_ioport m_io1;
required_ioport m_io2;