mirror of
https://github.com/holub/mame
synced 2025-07-06 10:29:38 +03:00
mcs51.cpp: converted serial_rx and serial_tx to devcb (nw)
This commit is contained in:
parent
1b49471f51
commit
83bc05a08b
@ -271,6 +271,8 @@ mcs51_cpu_device::mcs51_cpu_device(const machine_config &mconfig, device_type ty
|
||||
, m_features(features)
|
||||
, m_ram_mask( (data_width == 8) ? 0xFF : 0x7F )
|
||||
, m_num_interrupts(5)
|
||||
, m_serial_tx_cb(*this)
|
||||
, m_serial_rx_cb(*this)
|
||||
, m_rtemp(0)
|
||||
{
|
||||
m_ds5002fp.mcon = 0;
|
||||
@ -969,8 +971,7 @@ void mcs51_cpu_device::transmit_receive(int source)
|
||||
m_uart.bits_to_send--;
|
||||
if(m_uart.bits_to_send == 0) {
|
||||
//Call the callback function
|
||||
if(!m_serial_tx_callback.isnull())
|
||||
m_serial_tx_callback(*m_io, 0, m_uart.data_out, 0xff);
|
||||
m_serial_tx_cb(*m_io, 0, m_uart.data_out, 0xff);
|
||||
//Set Interrupt Flag
|
||||
SET_TI(1);
|
||||
}
|
||||
@ -988,8 +989,7 @@ void mcs51_cpu_device::transmit_receive(int source)
|
||||
{
|
||||
int data = 0;
|
||||
//Call our callball function to retrieve the data
|
||||
if(!m_serial_rx_callback.isnull())
|
||||
data = m_serial_rx_callback(*m_io, 0, 0xff);
|
||||
data = m_serial_rx_cb(*m_io, 0, 0xff);
|
||||
LOG(("RX Deliver %d\n", data));
|
||||
SET_SBUF(data);
|
||||
//Flag the IRQ
|
||||
@ -1322,20 +1322,6 @@ void mcs51_cpu_device::update_irq_prio(UINT8 ipl, UINT8 iph)
|
||||
m_irq_prio[i] = ((ipl >> i) & 1) | (((iph >>i ) & 1) << 1);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
CALLBACKS - TODO: Remove
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
void mcs51_cpu_device::i8051_set_serial_tx_callback(write8_delegate tx_func)
|
||||
{
|
||||
m_serial_tx_callback = tx_func;
|
||||
}
|
||||
|
||||
void mcs51_cpu_device::i8051_set_serial_rx_callback(read8_delegate rx_func)
|
||||
{
|
||||
m_serial_rx_callback = rx_func;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
OPCODES
|
||||
@ -2115,6 +2101,9 @@ void mcs51_cpu_device::device_start()
|
||||
|
||||
/* ensure these pointers are set before get_info is called */
|
||||
update_ptrs();
|
||||
|
||||
m_serial_rx_cb.resolve_safe(0);
|
||||
m_serial_tx_cb.resolve_safe();
|
||||
|
||||
/* Save states */
|
||||
|
||||
|
@ -32,6 +32,13 @@
|
||||
#define __MCS51_H__
|
||||
|
||||
|
||||
#define MCFG_MCS51_SERIAL_RX_CB(_devcb) \
|
||||
devcb = &mcs51_cpu_device::set_serial_rx_cb(*device, DEVCB_##_devcb);
|
||||
|
||||
#define MCFG_MCS51_SERIAL_TX_CB(_devcb) \
|
||||
devcb = &mcs51_cpu_device::set_serial_tx_cb(*device, DEVCB_##_devcb);
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MCS51_PC=1, MCS51_SP, MCS51_PSW, MCS51_ACC, MCS51_B, MCS51_DPH, MCS51_DPL, MCS51_IE,
|
||||
@ -79,11 +86,10 @@ public:
|
||||
// construction/destruction
|
||||
mcs51_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, int program_width, int data_width, UINT8 features = 0);
|
||||
|
||||
void i8051_set_serial_tx_callback(write8_delegate tx_func);
|
||||
void i8051_set_serial_rx_callback(read8_delegate rx_func);
|
||||
|
||||
// configuration helpers
|
||||
static void set_port_forced_input(device_t &device, UINT8 port, UINT8 forced_input) { downcast<mcs51_cpu_device &>(device).m_forced_inputs[port] = forced_input; }
|
||||
template<class _Object> static devcb_base & set_serial_rx_cb(device_t &device, _Object object) { return downcast<mcs51_cpu_device &>(device).m_serial_rx_cb.set_callback(object); }
|
||||
template<class _Object> static devcb_base & set_serial_tx_cb(device_t &device, _Object object) { return downcast<mcs51_cpu_device &>(device).m_serial_tx_cb.set_callback(object); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
@ -170,9 +176,8 @@ protected:
|
||||
address_space *m_io;
|
||||
|
||||
/* Serial Port TX/RX Callbacks */
|
||||
// TODO: Move to special port r/w
|
||||
write8_delegate m_serial_tx_callback; //Call back funciton when sending data out of serial port
|
||||
read8_delegate m_serial_rx_callback; //Call back function to retrieve data when receiving serial port data
|
||||
devcb_write8 m_serial_tx_cb; //Call back function when sending data out of serial port
|
||||
devcb_read8 m_serial_rx_cb; //Call back function to retrieve data when receiving serial port data
|
||||
|
||||
/* DS5002FP */
|
||||
struct {
|
||||
|
@ -156,6 +156,7 @@ static MACHINE_CONFIG_FRAGMENT( qs1000 )
|
||||
MCFG_CPU_ADD("cpu", I8052, DERIVED_CLOCK(1, 1))
|
||||
MCFG_CPU_PROGRAM_MAP(qs1000_prg_map)
|
||||
MCFG_CPU_IO_MAP(qs1000_io_map)
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(qs1000_device, data_to_i8052))
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
||||
@ -244,8 +245,6 @@ void qs1000_device::device_start()
|
||||
|
||||
//m_serial_w_cb.resolve_safe();
|
||||
|
||||
m_cpu->i8051_set_serial_rx_callback(read8_delegate(FUNC(qs1000_device::data_to_i8052),this));
|
||||
|
||||
save_item(NAME(m_serial_data_in));
|
||||
save_item(NAME(m_wave_regs));
|
||||
|
||||
|
@ -88,7 +88,6 @@ protected:
|
||||
// device_sound_interface overrides
|
||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
|
||||
|
||||
DECLARE_READ8_MEMBER( data_to_i8052 );
|
||||
public:
|
||||
DECLARE_WRITE8_MEMBER( wave_w );
|
||||
|
||||
@ -103,6 +102,8 @@ public:
|
||||
|
||||
DECLARE_READ8_MEMBER( p3_r );
|
||||
DECLARE_WRITE8_MEMBER( p3_w );
|
||||
|
||||
DECLARE_READ8_MEMBER( data_to_i8052 );
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -44,8 +44,7 @@ class basic52_state : public driver_device
|
||||
public:
|
||||
basic52_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_terminal(*this, TERMINAL_TAG)
|
||||
m_maincpu(*this, "maincpu")
|
||||
{
|
||||
}
|
||||
|
||||
@ -53,9 +52,6 @@ public:
|
||||
DECLARE_READ8_MEMBER(unk_r);
|
||||
UINT8 m_term_data;
|
||||
required_device<mcs51_cpu_device> m_maincpu;
|
||||
required_device<generic_terminal_device> m_terminal;
|
||||
virtual void machine_reset() override;
|
||||
DECLARE_WRITE8_MEMBER(to_term);
|
||||
DECLARE_READ8_MEMBER(from_term);
|
||||
};
|
||||
|
||||
@ -83,11 +79,6 @@ ADDRESS_MAP_END
|
||||
static INPUT_PORTS_START( basic52 )
|
||||
INPUT_PORTS_END
|
||||
|
||||
// won't compile unless these are static
|
||||
WRITE8_MEMBER( basic52_state::to_term)
|
||||
{
|
||||
m_terminal->write(space, 0, data);
|
||||
}
|
||||
|
||||
READ8_MEMBER(basic52_state::from_term)
|
||||
{
|
||||
@ -99,11 +90,6 @@ READ8_MEMBER( basic52_state::unk_r)
|
||||
return m_term_data; // won't boot without this
|
||||
}
|
||||
|
||||
void basic52_state::machine_reset()
|
||||
{
|
||||
m_maincpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(basic52_state::to_term),this));
|
||||
m_maincpu->i8051_set_serial_rx_callback(read8_delegate(FUNC(basic52_state::from_term),this));
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( basic52_state::kbd_put )
|
||||
{
|
||||
@ -117,7 +103,8 @@ static MACHINE_CONFIG_START( basic31, basic52_state )
|
||||
MCFG_CPU_ADD("maincpu", I8031, XTAL_11_0592MHz)
|
||||
MCFG_CPU_PROGRAM_MAP(basic52_mem)
|
||||
MCFG_CPU_IO_MAP(basic52_io)
|
||||
|
||||
MCFG_MCS51_SERIAL_TX_CB(DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(basic52_state, from_term))
|
||||
|
||||
/* video hardware */
|
||||
MCFG_DEVICE_ADD(TERMINAL_TAG, GENERIC_TERMINAL, 0)
|
||||
@ -131,6 +118,8 @@ static MACHINE_CONFIG_DERIVED( basic52, basic31 )
|
||||
MCFG_CPU_REPLACE("maincpu", I8052, XTAL_11_0592MHz)
|
||||
MCFG_CPU_PROGRAM_MAP(basic52_mem)
|
||||
MCFG_CPU_IO_MAP(basic52_io)
|
||||
MCFG_MCS51_SERIAL_TX_CB(DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(basic52_state, from_term))
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
/* ROM definition */
|
||||
|
@ -551,6 +551,7 @@ static MACHINE_CONFIG_START( eolith45, eolith_state )
|
||||
MCFG_CPU_ADD("soundcpu", I8032, XTAL_12MHz)
|
||||
MCFG_CPU_PROGRAM_MAP(sound_prg_map)
|
||||
MCFG_CPU_IO_MAP(sound_io_map)
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(eolith_state, soundcpu_to_qs1000)) // Sound CPU -> QS1000 CPU serial link
|
||||
|
||||
MCFG_MACHINE_RESET_OVERRIDE(eolith_state,eolith)
|
||||
|
||||
@ -593,7 +594,7 @@ MACHINE_CONFIG_END
|
||||
|
||||
static MACHINE_CONFIG_DERIVED( ironfort, eolith45 )
|
||||
MCFG_CPU_MODIFY("maincpu")
|
||||
MCFG_CPU_CLOCK(44900000) /* Normaly 45MHz??? but PCB actually had a 44.9MHz OSC, so it's value is used */
|
||||
MCFG_CPU_CLOCK(44900000) /* Normally 45MHz??? but PCB actually had a 44.9MHz OSC, so it's value is used */
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
||||
@ -1493,9 +1494,6 @@ DRIVER_INIT_MEMBER(eolith_state,eolith)
|
||||
{
|
||||
init_speedup();
|
||||
|
||||
// Sound CPU -> QS1000 CPU serial link
|
||||
m_soundcpu->i8051_set_serial_tx_callback(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);
|
||||
|
||||
|
@ -842,9 +842,6 @@ void maygayv1_state::machine_start()
|
||||
i82716.line_buf = std::make_unique<UINT8[]>(512);
|
||||
|
||||
save_pointer(NAME(i82716.dram.get()), 0x40000);
|
||||
|
||||
m_soundcpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(maygayv1_state::data_from_i8031),this));
|
||||
m_soundcpu->i8051_set_serial_rx_callback(read8_delegate(FUNC(maygayv1_state::data_to_i8031),this));
|
||||
}
|
||||
|
||||
void maygayv1_state::machine_reset()
|
||||
@ -872,6 +869,8 @@ static MACHINE_CONFIG_START( maygayv1, maygayv1_state )
|
||||
MCFG_CPU_PROGRAM_MAP(sound_prg)
|
||||
MCFG_CPU_DATA_MAP(sound_data)
|
||||
MCFG_CPU_IO_MAP(sound_io)
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(maygayv1_state, data_from_i8031))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(maygayv1_state, data_to_i8031))
|
||||
|
||||
/* U25 ST 2 9148 EF68B21P */
|
||||
MCFG_DEVICE_ADD("pia", PIA6821, 0)
|
||||
|
@ -309,6 +309,8 @@ static MACHINE_CONFIG_START( micro3d, micro3d_state )
|
||||
MCFG_CPU_ADD("audiocpu", I8051, XTAL_11_0592MHz)
|
||||
MCFG_CPU_PROGRAM_MAP(soundmem_prg)
|
||||
MCFG_CPU_IO_MAP(soundmem_io)
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(micro3d_state, data_from_i8031))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(micro3d_state, data_to_i8031))
|
||||
|
||||
MCFG_MC68681_ADD("duart68681", XTAL_3_6864MHz)
|
||||
MCFG_MC68681_IRQ_CALLBACK(WRITELINE(micro3d_state, duart_irq_handler))
|
||||
|
@ -218,12 +218,6 @@ void pes_state::machine_reset()
|
||||
timer_set(attotime::from_hz(10000), TIMER_OUTFIFO_READ);
|
||||
}*/
|
||||
|
||||
DRIVER_INIT_MEMBER(pes_state,pes)
|
||||
{
|
||||
m_maincpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(pes_state::data_from_i8031),this));
|
||||
m_maincpu->i8051_set_serial_rx_callback(read8_delegate(FUNC(pes_state::data_to_i8031),this));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Address Maps
|
||||
******************************************************************************/
|
||||
@ -255,6 +249,8 @@ static MACHINE_CONFIG_START( pes, pes_state )
|
||||
MCFG_CPU_ADD("maincpu", I80C31, CPU_CLOCK)
|
||||
MCFG_CPU_PROGRAM_MAP(i80c31_mem)
|
||||
MCFG_CPU_IO_MAP(i80c31_io)
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(pes_state, data_from_i8031))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(pes_state, data_to_i8031))
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
@ -282,4 +278,4 @@ ROM_END
|
||||
******************************************************************************/
|
||||
|
||||
/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */
|
||||
COMP( 1987, pes, 0, 0, pes, pes, pes_state, pes, "Pacific Educational Systems", "VPU-01 Speech box", MACHINE_NOT_WORKING )
|
||||
COMP( 1987, pes, 0, 0, pes, pes, driver_device, 0, "Pacific Educational Systems", "VPU-01 Speech box", MACHINE_NOT_WORKING )
|
||||
|
@ -26,7 +26,6 @@ public:
|
||||
m_ticket(*this, "ticket")
|
||||
{ }
|
||||
|
||||
virtual void machine_start() override;
|
||||
virtual void machine_reset() override;
|
||||
DECLARE_WRITE8_MEMBER(ctrl_w);
|
||||
DECLARE_WRITE8_MEMBER(mcs51_tx_callback);
|
||||
@ -113,12 +112,6 @@ static INPUT_PORTS_START( piggypas )
|
||||
INPUT_PORTS_END
|
||||
|
||||
|
||||
|
||||
void piggypas_state::machine_start()
|
||||
{
|
||||
m_maincpu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(piggypas_state, mcs51_tx_callback));
|
||||
}
|
||||
|
||||
void piggypas_state::machine_reset()
|
||||
{
|
||||
m_digit_idx = 0;
|
||||
@ -136,6 +129,7 @@ static MACHINE_CONFIG_START( piggypas, piggypas_state )
|
||||
MCFG_CPU_ADD("maincpu", I8031, 8000000) // unknown variant
|
||||
MCFG_CPU_PROGRAM_MAP(piggypas_map)
|
||||
MCFG_CPU_IO_MAP(piggypas_io)
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(piggypas_state, mcs51_tx_callback))
|
||||
// MCFG_CPU_VBLANK_INT_DRIVER("screen", piggypas_state, irq0_line_hold)
|
||||
|
||||
MCFG_SCREEN_ADD("screen", LCD)
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
DECLARE_WRITE8_MEMBER(port3_w);
|
||||
DECLARE_READ8_MEMBER(port1_r);
|
||||
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);
|
||||
|
@ -589,9 +589,6 @@ DRIVER_INIT_MEMBER(micro3d_state,micro3d)
|
||||
{
|
||||
address_space &space = m_drmath->space(AS_DATA);
|
||||
|
||||
m_audiocpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(micro3d_state::data_from_i8031),this));
|
||||
m_audiocpu->i8051_set_serial_rx_callback(read8_delegate(FUNC(micro3d_state::data_to_i8031),this));
|
||||
|
||||
/* The Am29000 program seems to rely on RAM from 0x00470000 onwards being
|
||||
non-zero on a reset, otherwise the 3D object data doesn't get uploaded! */
|
||||
space.write_dword(0x00470000, 0xa5a5a5a5);
|
||||
|
@ -113,6 +113,8 @@ ADDRESS_MAP_END
|
||||
static MACHINE_CONFIG_FRAGMENT( wangpc_keyboard )
|
||||
MCFG_CPU_ADD(I8051_TAG, I8051, XTAL_4MHz)
|
||||
MCFG_CPU_IO_MAP(wangpc_keyboard_io)
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(wangpc_keyboard_device, mcs51_tx_callback))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(wangpc_keyboard_device, mcs51_rx_callback))
|
||||
|
||||
// sound hardware
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
@ -403,9 +405,6 @@ void wangpc_keyboard_device::device_start()
|
||||
{
|
||||
m_txd_handler.resolve_safe();
|
||||
|
||||
// set serial callbacks
|
||||
m_maincpu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(wangpc_keyboard_device, mcs51_tx_callback));
|
||||
m_maincpu->i8051_set_serial_rx_callback(READ8_DELEGATE(wangpc_keyboard_device, mcs51_rx_callback));
|
||||
set_data_frame(1, 8, PARITY_NONE, STOP_BITS_2);
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,9 @@ static MACHINE_CONFIG_FRAGMENT( pcx_video )
|
||||
MCFG_CPU_ADD("graphics", I8031, XTAL_24MHz/2)
|
||||
MCFG_CPU_PROGRAM_MAP(pcx_vid_map)
|
||||
MCFG_CPU_IO_MAP(pcx_vid_io)
|
||||
|
||||
MCFG_MCS51_SERIAL_TX_CB(WRITE8(pcx_video_device, tx_callback))
|
||||
MCFG_MCS51_SERIAL_RX_CB(READ8(pcx_video_device, rx_callback))
|
||||
|
||||
// video hardware
|
||||
MCFG_SCREEN_ADD("screen", RASTER)
|
||||
@ -430,13 +433,9 @@ ADDRESS_MAP_END
|
||||
|
||||
void pcx_video_device::device_start()
|
||||
{
|
||||
mcs51_cpu_device *mcu = downcast<mcs51_cpu_device *>(m_mcu.target());
|
||||
m_maincpu->space(AS_IO).install_readwrite_handler(0xfb00, 0xfb01, read8_delegate(FUNC(pcdx_video_device::detect_r), this), write8_delegate(FUNC(pcdx_video_device::detect_w), this), 0x00ff);
|
||||
m_txd_handler.resolve_safe();
|
||||
|
||||
// set serial callbacks
|
||||
mcu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(pcx_video_device, tx_callback));
|
||||
mcu->i8051_set_serial_rx_callback(READ8_DELEGATE(pcx_video_device, rx_callback));
|
||||
set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
|
||||
set_rate(600*2); // FIXME: fix the keyboard when the mc2661 baud rate calc is fixed
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user