summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/tm990189.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/tm990189.cpp')
-rw-r--r--src/mame/drivers/tm990189.cpp106
1 files changed, 59 insertions, 47 deletions
diff --git a/src/mame/drivers/tm990189.cpp b/src/mame/drivers/tm990189.cpp
index 77a37924400..c148463760b 100644
--- a/src/mame/drivers/tm990189.cpp
+++ b/src/mame/drivers/tm990189.cpp
@@ -81,6 +81,8 @@
class tm990189_state : public driver_device
{
+ friend class tm990_189_rs232_image_device;
+
public:
tm990189_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
@@ -90,34 +92,14 @@ public:
, m_tms9918(*this, "tms9918")
, m_tms9901_usr(*this, TMS9901_0_TAG)
, m_tms9901_sys(*this, TMS9901_1_TAG)
+ , m_tms9902(*this, "tms9902")
, m_digits(*this, "digit%u", 0U)
{ }
- required_device<tms9980a_device> m_tms9980a;
- required_device<speaker_sound_device> m_speaker;
- required_device<cassette_image_device> m_cass;
- optional_device<tms9918_device> m_tms9918;
-
DECLARE_READ8_MEMBER(video_vdp_r);
DECLARE_WRITE8_MEMBER(video_vdp_w);
DECLARE_READ8_MEMBER(video_joy_r);
DECLARE_WRITE8_MEMBER(video_joy_w);
- int m_load_state;
-
- int m_digitsel;
- int m_segment;
- emu_timer *m_displayena_timer;
- uint8_t m_segment_state[10];
- uint8_t m_old_segment_state[10];
- uint8_t m_LED_state;
- emu_timer *m_joy1x_timer;
- emu_timer *m_joy1y_timer;
- emu_timer *m_joy2x_timer;
- emu_timer *m_joy2y_timer;
- device_image_interface *m_rs232_fp;
- uint8_t m_rs232_rts;
- emu_timer *m_rs232_input_timer;
- uint8_t m_bogus_read_save;
DECLARE_WRITE8_MEMBER( external_operation );
@@ -156,22 +138,51 @@ public:
DECLARE_MACHINE_START(tm990_189_v);
DECLARE_MACHINE_RESET(tm990_189_v);
- TIMER_DEVICE_CALLBACK_MEMBER(display_callback);
- TIMER_CALLBACK_MEMBER(clear_load);
- void hold_load();
void tm990_189_v(machine_config &config);
void tm990_189(machine_config &config);
+
+protected:
+ emu_timer *m_rs232_input_timer;
+
+private:
void tm990_189_cru_map(address_map &map);
void tm990_189_memmap(address_map &map);
void tm990_189_v_memmap(address_map &map);
-private:
+
void draw_digit(void);
void led_set(int number, bool state);
void segment_set(int offset, bool state);
void digitsel(int offset, bool state);
- required_device<tms9901_device> m_tms9901_usr;
- required_device<tms9901_device> m_tms9901_sys;
+
+ TIMER_DEVICE_CALLBACK_MEMBER(display_callback);
+ TIMER_CALLBACK_MEMBER(clear_load);
+ void hold_load();
+
+ required_device<tms9980a_device> m_tms9980a;
+ required_device<speaker_sound_device> m_speaker;
+ required_device<cassette_image_device> m_cass;
+ optional_device<tms9918_device> m_tms9918;
+
+ required_device<tms9901_device> m_tms9901_usr;
+ required_device<tms9901_device> m_tms9901_sys;
+ required_device<tms9902_device> m_tms9902;
output_finder<10> m_digits;
+
+ int m_load_state;
+
+ int m_digitsel;
+ int m_segment;
+ emu_timer *m_displayena_timer;
+ uint8_t m_segment_state[10];
+ uint8_t m_old_segment_state[10];
+ uint8_t m_LED_state;
+ emu_timer *m_joy1x_timer;
+ emu_timer *m_joy1y_timer;
+ emu_timer *m_joy2x_timer;
+ emu_timer *m_joy2y_timer;
+ device_image_interface *m_rs232_fp;
+ uint8_t m_rs232_rts;
+ uint8_t m_bogus_read_save;
};
@@ -313,7 +324,6 @@ WRITE_LINE_MEMBER( tm990189_state::usr9901_led3_w )
WRITE8_MEMBER( tm990189_state::sys9901_interrupt_callback )
{
- // machine().device<tms9901_device>("tms9901_0")->set_single_int(5, (data!=0)? ASSERT_LINE:CLEAR_LINE);
// TODO: Check this
m_tms9901_usr->set_single_int(5, (data!=0)? ASSERT_LINE:CLEAR_LINE);
}
@@ -435,11 +445,16 @@ WRITE_LINE_MEMBER( tm990189_state::sys9901_tapewdata_w )
m_cass->output(state ? +1.0 : -1.0);
}
-class tm990_189_rs232_image_device : public device_t,
- public device_image_interface
+class tm990_189_rs232_image_device : public device_t, public device_image_interface
{
public:
// construction/destruction
+ template <typename T> tm990_189_rs232_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&tms_tag)
+ : tm990_189_rs232_image_device(mconfig, tag, owner, clock)
+ {
+ m_tms9902.set_tag(std::forward<T>(tms_tag));
+ }
+
tm990_189_rs232_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// image-level overrides
@@ -456,9 +471,12 @@ public:
virtual image_init_result call_load() override;
virtual void call_unload() override;
+
protected:
// device-level overrides
virtual void device_start() override;
+
+ required_device<tms9902_device> m_tms9902;
};
DEFINE_DEVICE_TYPE(TM990_189_RS232, tm990_189_rs232_image_device, "tm990_189_rs232_image", "TM990/189 RS232 port")
@@ -466,6 +484,7 @@ DEFINE_DEVICE_TYPE(TM990_189_RS232, tm990_189_rs232_image_device, "tm990_189_rs2
tm990_189_rs232_image_device::tm990_189_rs232_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, TM990_189_RS232, tag, owner, clock)
, device_image_interface(mconfig, *this)
+ , m_tms9902(*this, finder_base::DUMMY_TAG)
{
}
@@ -475,21 +494,18 @@ void tm990_189_rs232_image_device::device_start()
void tm990_189_rs232_image_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
- //tm990189_state *state = machine.driver_data<tm990189_state>();
uint8_t buf;
- if (/*state->m_rs232_rts &&*/ /*(mame_ftell(state->m_rs232_fp) < mame_fsize(state->m_rs232_fp))*/1)
+ if (/*m_rs232_rts &&*/ /*(mame_ftell(m_rs232_fp) < mame_fsize(m_rs232_fp))*/1)
{
- tms9902_device* tms9902 = static_cast<tms9902_device*>(machine().device("tms9902"));
if (fread(&buf, 1) == 1)
- tms9902->rcv_data(buf);
+ m_tms9902->rcv_data(buf);
}
}
image_init_result tm990_189_rs232_image_device::call_load()
{
tm990189_state *state = machine().driver_data<tm990189_state>();
- tms9902_device* tms9902 = static_cast<tms9902_device*>(machine().device("tms9902"));
- tms9902->rcv_dsr(ASSERT_LINE);
+ m_tms9902->rcv_dsr(ASSERT_LINE);
state->m_rs232_input_timer = timer_alloc();
state->m_rs232_input_timer->adjust(attotime::zero, 0, attotime::from_msec(10));
return image_init_result::PASS;
@@ -499,15 +515,11 @@ image_init_result tm990_189_rs232_image_device::call_load()
void tm990_189_rs232_image_device::call_unload()
{
tm990189_state *state = machine().driver_data<tm990189_state>();
- tms9902_device* tms9902 = static_cast<tms9902_device*>(machine().device("tms9902"));
- tms9902->rcv_dsr(CLEAR_LINE);
+ m_tms9902->rcv_dsr(CLEAR_LINE);
state->m_rs232_input_timer->reset(); /* FIXME - timers should only be allocated once */
}
-#define MCFG_TM990_189_RS232_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, TM990_189_RS232, 0)
-
/* static TMS9902_RTS_CALLBACK( rts_callback )
{
@@ -804,11 +816,11 @@ void tm990189_state::tm990_189_cru_map(address_map &map)
{
map(0x0000, 0x003f).r(m_tms9901_usr, FUNC(tms9901_device::read)); /* user I/O tms9901 */
map(0x0040, 0x006f).r(m_tms9901_sys, FUNC(tms9901_device::read)); /* system I/O tms9901 */
- map(0x0080, 0x00cf).r("tms9902", FUNC(tms9902_device::cruread)); /* optional tms9902 */
+ map(0x0080, 0x00cf).r(m_tms9902, FUNC(tms9902_device::cruread)); /* optional tms9902 */
map(0x0000, 0x01ff).w(m_tms9901_usr, FUNC(tms9901_device::write)); /* user I/O tms9901 */
map(0x0200, 0x03ff).w(m_tms9901_sys, FUNC(tms9901_device::write)); /* system I/O tms9901 */
- map(0x0400, 0x05ff).w("tms9902", FUNC(tms9902_device::cruwrite)); /* optional tms9902 */
+ map(0x0400, 0x05ff).w(m_tms9902, FUNC(tms9902_device::cruwrite)); /* optional tms9902 */
}
MACHINE_CONFIG_START(tm990189_state::tm990_189)
@@ -857,9 +869,9 @@ MACHINE_CONFIG_START(tm990189_state::tm990_189)
MCFG_TMS9901_P15_HANDLER( WRITELINE( *this, tm990189_state, sys9901_tapewdata_w) )
MCFG_TMS9901_INTLEVEL_HANDLER( WRITE8( *this, tm990189_state, sys9901_interrupt_callback) )
- MCFG_DEVICE_ADD("tms9902", TMS9902, 2000000) // MZ: needs to be fixed once the RS232 support is complete
+ MCFG_DEVICE_ADD(m_tms9902, TMS9902, 2000000) // MZ: needs to be fixed once the RS232 support is complete
MCFG_TMS9902_XMIT_CB(WRITE8(*this, tm990189_state, xmit_callback)) /* called when a character is transmitted */
- MCFG_TM990_189_RS232_ADD("rs232")
+ MCFG_DEVICE_ADD("rs232", TM990_189_RS232, 0, m_tms9902)
MCFG_TIMER_DRIVER_ADD_PERIODIC("display_timer", tm990189_state, display_callback, attotime::from_hz(30))
// Need to delay the timer, or it will spoil the initial LOAD
// TODO: Fix this, probably inside CPU
@@ -915,9 +927,9 @@ MACHINE_CONFIG_START(tm990189_state::tm990_189_v)
MCFG_TMS9901_P15_HANDLER( WRITELINE( *this, tm990189_state, sys9901_tapewdata_w) )
MCFG_TMS9901_INTLEVEL_HANDLER( WRITE8( *this, tm990189_state, sys9901_interrupt_callback) )
- MCFG_DEVICE_ADD("tms9902", TMS9902, 2000000) // MZ: needs to be fixed once the RS232 support is complete
+ MCFG_DEVICE_ADD(m_tms9902, TMS9902, 2000000) // MZ: needs to be fixed once the RS232 support is complete
MCFG_TMS9902_XMIT_CB(WRITE8(*this, tm990189_state, xmit_callback)) /* called when a character is transmitted */
- MCFG_TM990_189_RS232_ADD("rs232")
+ MCFG_DEVICE_ADD("rs232", TM990_189_RS232, 0, m_tms9902)
MCFG_TIMER_DRIVER_ADD_PERIODIC("display_timer", tm990189_state, display_callback, attotime::from_hz(30))
MCFG_TIMER_START_DELAY(attotime::from_msec(150))
MACHINE_CONFIG_END