summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/tk2000.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/tk2000.cpp')
-rw-r--r--src/mame/drivers/tk2000.cpp65
1 files changed, 34 insertions, 31 deletions
diff --git a/src/mame/drivers/tk2000.cpp b/src/mame/drivers/tk2000.cpp
index 38280fb3e63..6b0d3156d02 100644
--- a/src/mame/drivers/tk2000.cpp
+++ b/src/mame/drivers/tk2000.cpp
@@ -18,6 +18,7 @@
#include "video/apple2.h"
#include "cpu/m6502/m6502.h"
+#include "bus/centronics/ctronics.h"
#include "imagedev/cassette.h"
#include "machine/74259.h"
#include "machine/bankdev.h"
@@ -48,20 +49,14 @@ public:
m_ram(*this, RAM_TAG),
m_screen(*this, "screen"),
m_video(*this, A2_VIDEO_TAG),
- m_row0(*this, "ROW0"),
- m_row1(*this, "ROW1"),
- m_row2(*this, "ROW2"),
- m_row3(*this, "ROW3"),
- m_row4(*this, "ROW4"),
- m_row5(*this, "ROW5"),
- m_row6(*this, "ROW6"),
- m_row7(*this, "ROW7"),
+ m_row(*this, "ROW%u", 0U),
m_kbspecial(*this, "keyb_special"),
m_sysconfig(*this, "a2_config"),
m_speaker(*this, A2_SPEAKER_TAG),
m_cassette(*this, A2_CASSETTE_TAG),
m_upperbank(*this, A2_UPPERBANK_TAG),
- m_softlatch(*this, "softlatch")
+ m_softlatch(*this, "softlatch"),
+ m_printer(*this, "printer")
{ }
void tk2000(machine_config &config);
@@ -75,13 +70,14 @@ private:
required_device<ram_device> m_ram;
required_device<screen_device> m_screen;
required_device<a2_video_device> m_video;
- required_ioport m_row0, m_row1, m_row2, m_row3, m_row4, m_row5, m_row6, m_row7;
+ required_ioport_array<8> m_row;
required_ioport m_kbspecial;
required_ioport m_sysconfig;
required_device<speaker_sound_device> m_speaker;
required_device<cassette_image_device> m_cassette;
required_device<address_map_bank_device> m_upperbank;
required_device<addressable_latch_device> m_softlatch;
+ required_device<centronics_device> m_printer;
int m_speaker_state;
int m_cassette_state;
@@ -90,6 +86,7 @@ private:
uint8_t *m_ram_ptr;
int m_ram_size;
+ bool m_printer_busy;
TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt);
@@ -97,6 +94,8 @@ private:
uint8_t ram_r(offs_t offset);
void ram_w(offs_t offset, uint8_t data);
+
+ DECLARE_WRITE_LINE_MEMBER(printer_busy_w);
void kbout_w(uint8_t data);
uint8_t kbin_r();
uint8_t casout_r();
@@ -108,7 +107,6 @@ private:
DECLARE_WRITE_LINE_MEMBER(color_w);
DECLARE_WRITE_LINE_MEMBER(motor_a_w);
DECLARE_WRITE_LINE_MEMBER(motor_b_w);
- DECLARE_WRITE_LINE_MEMBER(printer_strobe_w);
DECLARE_WRITE_LINE_MEMBER(rom_ram_w);
DECLARE_WRITE_LINE_MEMBER(ctrl_key_w);
uint8_t c080_r(offs_t offset);
@@ -134,11 +132,13 @@ void tk2000_state::machine_start()
m_speaker->level_w(m_speaker_state);
m_cassette_state = 0;
m_cassette->output(-1.0f);
+ m_printer_busy = false;
// setup save states
save_item(NAME(m_speaker_state));
save_item(NAME(m_cassette_state));
save_item(NAME(m_strobe));
+ save_item(NAME(m_printer_busy));
// setup video pointers
m_video->m_ram_ptr = m_ram_ptr;
@@ -180,28 +180,32 @@ uint32_t tk2000_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
I/O
***************************************************************************/
+WRITE_LINE_MEMBER(tk2000_state::printer_busy_w)
+{
+ m_printer_busy = state;
+}
+
void tk2000_state::kbout_w(uint8_t data)
{
// write row mask for keyboard scan
- switch (data)
- {
- case 0:
- break;
-
- case 0x01: m_strobe = m_row0->read(); break;
- case 0x02: m_strobe = m_row1->read(); break;
- case 0x04: m_strobe = m_row2->read(); break;
- case 0x08: m_strobe = m_row3->read(); break;
- case 0x10: m_strobe = m_row4->read(); break;
- case 0x20: m_strobe = m_row5->read(); break;
- case 0x40: m_strobe = m_row6->read(); break;
- case 0x80: m_strobe = m_row7->read(); break;
- }
+ m_strobe = 0xff;
+ for (int i = 0; i < 8; i++)
+ if (BIT(data, i))
+ m_strobe &= m_row[i]->read();
+
+ m_printer->write_data0(BIT(data, 0));
+ m_printer->write_data1(BIT(data, 1));
+ m_printer->write_data2(BIT(data, 2));
+ m_printer->write_data3(BIT(data, 3));
+ m_printer->write_data4(BIT(data, 4));
+ m_printer->write_data5(BIT(data, 5));
+ m_printer->write_data6(BIT(data, 6));
+ m_printer->write_data7(BIT(data, 7));
}
uint8_t tk2000_state::kbin_r()
{
- return m_strobe;
+ return m_strobe | (m_printer_busy ? 0x40 : 0);
}
uint8_t tk2000_state::casout_r()
@@ -255,10 +259,6 @@ WRITE_LINE_MEMBER(tk2000_state::motor_b_w)
{
}
-WRITE_LINE_MEMBER(tk2000_state::printer_strobe_w)
-{
-}
-
WRITE_LINE_MEMBER(tk2000_state::rom_ram_w)
{
// 0 = ROM, 1 = RAM
@@ -597,7 +597,7 @@ void tk2000_state::tk2000(machine_config &config)
m_softlatch->q_out_cb<1>().set(FUNC(tk2000_state::motor_a_w));
m_softlatch->q_out_cb<2>().set(m_video, FUNC(a2_video_device::scr_w));
m_softlatch->q_out_cb<3>().set(FUNC(tk2000_state::motor_b_w));
- m_softlatch->q_out_cb<4>().set(FUNC(tk2000_state::printer_strobe_w));
+ m_softlatch->q_out_cb<4>().set(m_printer, FUNC(centronics_device::write_strobe));
m_softlatch->q_out_cb<5>().set(FUNC(tk2000_state::rom_ram_w));
m_softlatch->q_out_cb<7>().set(FUNC(tk2000_state::ctrl_key_w));
@@ -605,6 +605,9 @@ void tk2000_state::tk2000(machine_config &config)
CASSETTE(config, m_cassette);
m_cassette->set_default_state(CASSETTE_STOPPED);
+
+ CENTRONICS(config, m_printer, centronics_devices, nullptr);
+ m_printer->busy_handler().set(FUNC(tk2000_state::printer_busy_w));
}
/***************************************************************************