mirror of
https://github.com/holub/mame
synced 2025-04-26 02:07:14 +03:00
make mcs51 callbacks used delegates (nw)
This commit is contained in:
parent
c7997dab4b
commit
72c391a1e9
@ -290,8 +290,8 @@ struct mcs51_state_t
|
||||
|
||||
/* Serial Port TX/RX Callbacks */
|
||||
// TODO: Move to special port r/w
|
||||
mcs51_serial_tx_func serial_tx_callback; //Call back funciton when sending data out of serial port
|
||||
mcs51_serial_rx_func serial_rx_callback; //Call back function to retrieve data when receiving serial port data
|
||||
write8_delegate serial_tx_callback; //Call back funciton when sending data out of serial port
|
||||
read8_delegate serial_rx_callback; //Call back function to retrieve data when receiving serial port data
|
||||
|
||||
/* DS5002FP */
|
||||
struct {
|
||||
@ -925,8 +925,8 @@ INLINE void transmit_receive(mcs51_state_t *mcs51_state, int source)
|
||||
mcs51_state->uart.bits_to_send--;
|
||||
if(mcs51_state->uart.bits_to_send == 0) {
|
||||
//Call the callback function
|
||||
if(mcs51_state->serial_tx_callback)
|
||||
mcs51_state->serial_tx_callback(mcs51_state->device, mcs51_state->uart.data_out);
|
||||
if(!mcs51_state->serial_tx_callback.isnull())
|
||||
mcs51_state->serial_tx_callback(*mcs51_state->io, 0, mcs51_state->uart.data_out, 0xff);
|
||||
//Set Interrupt Flag
|
||||
SET_TI(1);
|
||||
}
|
||||
@ -944,8 +944,8 @@ INLINE void transmit_receive(mcs51_state_t *mcs51_state, int source)
|
||||
{
|
||||
int data = 0;
|
||||
//Call our callball function to retrieve the data
|
||||
if(mcs51_state->serial_rx_callback)
|
||||
data = mcs51_state->serial_rx_callback(mcs51_state->device);
|
||||
if(!mcs51_state->serial_rx_callback.isnull())
|
||||
data = mcs51_state->serial_rx_callback(*mcs51_state->io, 0, 0xff);
|
||||
LOG(("RX Deliver %d\n", data));
|
||||
SET_SBUF(data);
|
||||
//Flag the IRQ
|
||||
@ -1283,13 +1283,13 @@ INLINE void update_irq_prio(mcs51_state_t *mcs51_state, UINT8 ipl, UINT8 iph)
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
void i8051_set_serial_tx_callback(device_t *device, mcs51_serial_tx_func tx_func)
|
||||
void i8051_set_serial_tx_callback(device_t *device, write8_delegate tx_func)
|
||||
{
|
||||
mcs51_state_t *mcs51_state = get_safe_token(device);
|
||||
mcs51_state->serial_tx_callback = tx_func;
|
||||
}
|
||||
|
||||
void i8051_set_serial_rx_callback(device_t *device, mcs51_serial_rx_func rx_func)
|
||||
void i8051_set_serial_rx_callback(device_t *device, read8_delegate rx_func)
|
||||
{
|
||||
mcs51_state_t *mcs51_state = get_safe_token(device);
|
||||
mcs51_state->serial_rx_callback = rx_func;
|
||||
|
@ -87,12 +87,8 @@ struct ds5002fp_config
|
||||
/***************************************************************************
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
typedef void (*mcs51_serial_tx_func)(device_t *device, int data);
|
||||
typedef int (*mcs51_serial_rx_func)(device_t *device);
|
||||
|
||||
extern void i8051_set_serial_tx_callback(device_t *device, mcs51_serial_tx_func tx_func);
|
||||
extern void i8051_set_serial_rx_callback(device_t *device, mcs51_serial_rx_func rx_func);
|
||||
extern void i8051_set_serial_tx_callback(device_t *device, write8_delegate tx_func);
|
||||
extern void i8051_set_serial_rx_callback(device_t *device, read8_delegate rx_func);
|
||||
|
||||
/* variants with no internal rom and 128 byte internal memory */
|
||||
DECLARE_LEGACY_CPU_DEVICE(I8031, i8031);
|
||||
|
@ -133,9 +133,6 @@
|
||||
// device type definition
|
||||
const device_type QS1000 = &device_creator<qs1000_device>;
|
||||
|
||||
static int data_to_i8052(device_t *device);
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
@ -237,7 +234,7 @@ void qs1000_device::device_start()
|
||||
m_p2_w_func.resolve(m_out_p2_cb, *this);
|
||||
m_p3_w_func.resolve(m_out_p3_cb, *this);
|
||||
|
||||
i8051_set_serial_rx_callback(m_cpu, data_to_i8052);
|
||||
i8051_set_serial_rx_callback(m_cpu, read8_delegate(FUNC(qs1000_device::data_to_i8052),this));
|
||||
|
||||
// TODO: register state for saving
|
||||
}
|
||||
@ -270,12 +267,9 @@ void qs1000_device::set_irq(int state)
|
||||
// data_to_i8052 - called by the 8052 core to
|
||||
// receive serial data
|
||||
//-------------------------------------------------
|
||||
static int data_to_i8052(device_t *device)
|
||||
READ8_MEMBER(qs1000_device::data_to_i8052)
|
||||
{
|
||||
// Ugh
|
||||
qs1000_device *qs1000 = device->machine().device<qs1000_device>("qs1000");
|
||||
|
||||
return qs1000->m_serial_data_in;
|
||||
return m_serial_data_in;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,6 +82,7 @@ protected:
|
||||
// device_sound_interface overrides
|
||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
|
||||
|
||||
DECLARE_READ8_MEMBER( data_to_i8052 );
|
||||
public:
|
||||
DECLARE_WRITE8_MEMBER( wave_w );
|
||||
|
||||
|
@ -225,11 +225,10 @@ WRITE8_MEMBER( eolith_state::qs1000_p1_w )
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static void soundcpu_to_qs1000(device_t *device, int data)
|
||||
WRITE8_MEMBER(eolith_state::soundcpu_to_qs1000)
|
||||
{
|
||||
eolith_state *state = device->machine().driver_data<eolith_state>();
|
||||
state->m_qs1000->serial_in(data);
|
||||
device->machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
|
||||
m_qs1000->serial_in(data);
|
||||
machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
|
||||
}
|
||||
|
||||
|
||||
@ -1478,7 +1477,7 @@ DRIVER_INIT_MEMBER(eolith_state,eolith)
|
||||
init_eolith_speedup(machine());
|
||||
|
||||
// Sound CPU -> QS1000 CPU serial link
|
||||
i8051_set_serial_tx_callback(machine().device("soundcpu"), soundcpu_to_qs1000);
|
||||
i8051_set_serial_tx_callback(machine().device("soundcpu"), write8_delegate(FUNC(eolith_state::soundcpu_to_qs1000),this));
|
||||
|
||||
// Configure the sound ROM banking
|
||||
membank("sound_bank")->configure_entries(0, 16, memregion("sounddata")->base(), 0x8000);
|
||||
|
@ -244,6 +244,8 @@ public:
|
||||
UINT32 screen_update_maygayv1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
void screen_eof_maygayv1(screen_device &screen, bool state);
|
||||
INTERRUPT_GEN_MEMBER(vsync_interrupt);
|
||||
DECLARE_WRITE8_MEMBER(data_from_i8031);
|
||||
DECLARE_READ8_MEMBER(data_to_i8031);
|
||||
};
|
||||
|
||||
|
||||
@ -959,16 +961,14 @@ static const duart68681_config maygayv1_duart68681_config =
|
||||
};
|
||||
|
||||
|
||||
static int data_to_i8031(device_t *device)
|
||||
READ8_MEMBER(maygayv1_state::data_to_i8031)
|
||||
{
|
||||
maygayv1_state *state = device->machine().driver_data<maygayv1_state>();
|
||||
return state->m_d68681_val;
|
||||
return m_d68681_val;
|
||||
}
|
||||
|
||||
static void data_from_i8031(device_t *device, int data)
|
||||
WRITE8_MEMBER(maygayv1_state::data_from_i8031)
|
||||
{
|
||||
maygayv1_state *state = device->machine().driver_data<maygayv1_state>();
|
||||
duart68681_rx_data(state->m_duart68681, 0, data);
|
||||
duart68681_rx_data(m_duart68681, 0, data);
|
||||
}
|
||||
|
||||
READ8_MEMBER(maygayv1_state::b_read)
|
||||
@ -1011,8 +1011,8 @@ void maygayv1_state::machine_start()
|
||||
|
||||
// duart_68681_init(DUART_CLOCK, duart_irq_handler, duart_tx);
|
||||
|
||||
i8051_set_serial_tx_callback(machine().device("soundcpu"), data_from_i8031);
|
||||
i8051_set_serial_rx_callback(machine().device("soundcpu"), data_to_i8031);
|
||||
i8051_set_serial_tx_callback(machine().device("soundcpu"), write8_delegate(FUNC(maygayv1_state::data_from_i8031),this));
|
||||
i8051_set_serial_rx_callback(machine().device("soundcpu"), read8_delegate(FUNC(maygayv1_state::data_to_i8031),this));
|
||||
}
|
||||
|
||||
void maygayv1_state::machine_reset()
|
||||
|
@ -61,4 +61,5 @@ public:
|
||||
DECLARE_VIDEO_START(eolith);
|
||||
UINT32 screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(eolith_speedup);
|
||||
DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000);
|
||||
};
|
||||
|
@ -118,6 +118,8 @@ public:
|
||||
TIMER_CALLBACK_MEMBER(mac_done_callback);
|
||||
TIMER_CALLBACK_MEMBER(adc_done_callback);
|
||||
DECLARE_WRITE8_MEMBER(micro3d_upd7759_w);
|
||||
DECLARE_WRITE8_MEMBER(data_from_i8031);
|
||||
DECLARE_READ8_MEMBER(data_to_i8031);
|
||||
};
|
||||
|
||||
struct micro3d_vtx
|
||||
|
@ -53,16 +53,14 @@ void micro3d_duart_tx(device_t *device, int channel, UINT8 data)
|
||||
}
|
||||
};
|
||||
|
||||
static int data_to_i8031(device_t *device)
|
||||
READ8_MEMBER(micro3d_state::data_to_i8031)
|
||||
{
|
||||
micro3d_state *state = device->machine().driver_data<micro3d_state>();
|
||||
return state->m_m68681_tx0;
|
||||
return m_m68681_tx0;
|
||||
}
|
||||
|
||||
static void data_from_i8031(device_t *device, int data)
|
||||
WRITE8_MEMBER(micro3d_state::data_from_i8031)
|
||||
{
|
||||
micro3d_state *state = device->machine().driver_data<micro3d_state>();
|
||||
duart68681_rx_data(state->m_duart68681, 1, data);
|
||||
duart68681_rx_data(m_duart68681, 1, data);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -603,8 +601,8 @@ DRIVER_INIT_MEMBER(micro3d_state,micro3d)
|
||||
{
|
||||
address_space &space = machine().device("drmath")->memory().space(AS_DATA);
|
||||
|
||||
i8051_set_serial_tx_callback(machine().device("audiocpu"), data_from_i8031);
|
||||
i8051_set_serial_rx_callback(machine().device("audiocpu"), data_to_i8031);
|
||||
i8051_set_serial_tx_callback(machine().device("audiocpu"), write8_delegate(FUNC(micro3d_state::data_from_i8031),this));
|
||||
i8051_set_serial_rx_callback(machine().device("audiocpu"), read8_delegate(FUNC(micro3d_state::data_to_i8031),this));
|
||||
|
||||
m_duart68681 = machine().device("duart68681");
|
||||
|
||||
|
@ -50,6 +50,8 @@ public:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<generic_terminal_device> m_terminal;
|
||||
virtual void machine_reset();
|
||||
DECLARE_WRITE8_MEMBER(to_term);
|
||||
DECLARE_READ8_MEMBER(from_term);
|
||||
};
|
||||
|
||||
|
||||
@ -77,17 +79,14 @@ static INPUT_PORTS_START( basic52 )
|
||||
INPUT_PORTS_END
|
||||
|
||||
// won't compile unless these are static
|
||||
static void to_term(device_t *device, int data )
|
||||
WRITE8_MEMBER( basic52_state::to_term)
|
||||
{
|
||||
basic52_state *state = device->machine().driver_data<basic52_state>();
|
||||
address_space &space = device->memory().space(AS_PROGRAM);
|
||||
state->m_terminal->write(space, 0, data);
|
||||
m_terminal->write(space, 0, data);
|
||||
}
|
||||
|
||||
static int from_term(device_t *device)
|
||||
READ8_MEMBER(basic52_state::from_term)
|
||||
{
|
||||
basic52_state *state = device->machine().driver_data<basic52_state>();
|
||||
return state->m_term_data;
|
||||
return m_term_data;
|
||||
}
|
||||
|
||||
READ8_MEMBER( basic52_state::unk_r)
|
||||
@ -97,8 +96,8 @@ READ8_MEMBER( basic52_state::unk_r)
|
||||
|
||||
void basic52_state::machine_reset()
|
||||
{
|
||||
i8051_set_serial_tx_callback(m_maincpu, to_term);
|
||||
i8051_set_serial_rx_callback(m_maincpu, from_term);
|
||||
i8051_set_serial_tx_callback(m_maincpu, write8_delegate(FUNC(basic52_state::to_term),this));
|
||||
i8051_set_serial_rx_callback(m_maincpu, read8_delegate(FUNC(basic52_state::from_term),this));
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( basic52_state::kbd_put )
|
||||
|
@ -96,24 +96,22 @@ static GENERIC_TERMINAL_INTERFACE( pes_terminal_intf )
|
||||
};
|
||||
|
||||
/* Helper Functions */
|
||||
static int data_to_i8031(device_t *device)
|
||||
READ8_MEMBER( pes_state::data_to_i8031)
|
||||
{
|
||||
pes_state *state = device->machine().driver_data<pes_state>();
|
||||
UINT8 data;
|
||||
data = state->m_infifo[state->m_infifo_tail_ptr];
|
||||
data = m_infifo[m_infifo_tail_ptr];
|
||||
// if fifo is empty (tail ptr == head ptr), do not increment the tail ptr, otherwise do.
|
||||
if (state->m_infifo_tail_ptr != state->m_infifo_head_ptr) state->m_infifo_tail_ptr++;
|
||||
state->m_infifo_tail_ptr&=0x1F;
|
||||
if (m_infifo_tail_ptr != m_infifo_head_ptr) m_infifo_tail_ptr++;
|
||||
m_infifo_tail_ptr&=0x1F;
|
||||
#ifdef DEBUG_SERIAL_CB
|
||||
fprintf(stderr,"callback: input to i8031/pes from pc/terminal: %02X\n",data);
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
|
||||
static void data_from_i8031(device_t *device, int data)
|
||||
WRITE8_MEMBER(pes_state::data_from_i8031)
|
||||
{
|
||||
pes_state *state = device->machine().driver_data<pes_state>();
|
||||
state->m_terminal->write(device->machine().driver_data()->generic_space(),0,data);
|
||||
m_terminal->write(space,0,data);
|
||||
#ifdef DEBUG_SERIAL_CB
|
||||
fprintf(stderr,"callback: output from i8031/pes to pc/terminal: %02X\n",data);
|
||||
#endif
|
||||
@ -230,8 +228,8 @@ void pes_state::machine_reset()
|
||||
|
||||
DRIVER_INIT_MEMBER(pes_state,pes)
|
||||
{
|
||||
i8051_set_serial_tx_callback(machine().device("maincpu"), data_from_i8031);
|
||||
i8051_set_serial_rx_callback(machine().device("maincpu"), data_to_i8031);
|
||||
i8051_set_serial_tx_callback(machine().device("maincpu"), write8_delegate(FUNC(pes_state::data_from_i8031),this));
|
||||
i8051_set_serial_rx_callback(machine().device("maincpu"), read8_delegate(FUNC(pes_state::data_to_i8031),this));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
DECLARE_READ8_MEMBER(port3_r);
|
||||
DECLARE_DRIVER_INIT(pes);
|
||||
DECLARE_WRITE8_MEMBER(pes_kbd_input);
|
||||
DECLARE_READ8_MEMBER(data_to_i8031);
|
||||
DECLARE_WRITE8_MEMBER(data_from_i8031);
|
||||
};
|
||||
|
||||
|
||||
|
@ -413,8 +413,8 @@ wangpc_keyboard_device::wangpc_keyboard_device(const machine_config &mconfig, co
|
||||
void wangpc_keyboard_device::device_start()
|
||||
{
|
||||
// set serial callbacks
|
||||
i8051_set_serial_tx_callback(m_maincpu, wangpc_keyboard_device::mcs51_tx_callback);
|
||||
i8051_set_serial_rx_callback(m_maincpu, wangpc_keyboard_device::mcs51_rx_callback);
|
||||
i8051_set_serial_tx_callback(m_maincpu, write8_delegate(FUNC(wangpc_keyboard_device::mcs51_tx_callback),this));
|
||||
i8051_set_serial_rx_callback(m_maincpu, read8_delegate(FUNC(wangpc_keyboard_device::mcs51_rx_callback),this));
|
||||
set_data_frame(8, 2, SERIAL_PARITY_NONE);
|
||||
}
|
||||
|
||||
@ -457,11 +457,9 @@ void wangpc_keyboard_device::input_callback(UINT8 state)
|
||||
// mcs51_rx_callback -
|
||||
//-------------------------------------------------
|
||||
|
||||
int wangpc_keyboard_device::mcs51_rx_callback(device_t *device)
|
||||
READ8_MEMBER(wangpc_keyboard_device::mcs51_rx_callback)
|
||||
{
|
||||
wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
|
||||
|
||||
return kb->get_received_char();
|
||||
return get_received_char();
|
||||
}
|
||||
|
||||
|
||||
@ -469,18 +467,16 @@ int wangpc_keyboard_device::mcs51_rx_callback(device_t *device)
|
||||
// mcs51_tx_callback -
|
||||
//-------------------------------------------------
|
||||
|
||||
void wangpc_keyboard_device::mcs51_tx_callback(device_t *device, int data)
|
||||
WRITE8_MEMBER(wangpc_keyboard_device::mcs51_tx_callback)
|
||||
{
|
||||
wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
|
||||
|
||||
if (LOG) logerror("Wang PC keyboard transmit data %02x\n", data);
|
||||
|
||||
kb->transmit_register_setup(data);
|
||||
transmit_register_setup(data);
|
||||
|
||||
// HACK bang the bits out immediately
|
||||
while (!kb->is_transmit_register_empty())
|
||||
while (!is_transmit_register_empty())
|
||||
{
|
||||
kb->transmit_register_send_bit();
|
||||
transmit_register_send_bit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ public:
|
||||
DECLARE_WRITE8_MEMBER( kb_p2_w );
|
||||
DECLARE_WRITE8_MEMBER( kb_p3_w );
|
||||
|
||||
static int mcs51_rx_callback(device_t *device);
|
||||
static void mcs51_tx_callback(device_t *device, int data);
|
||||
DECLARE_READ8_MEMBER(mcs51_rx_callback);
|
||||
DECLARE_WRITE8_MEMBER(mcs51_tx_callback);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
|
Loading…
Reference in New Issue
Block a user