mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
tk2000: Add printer interface
This commit is contained in:
parent
d57439b609
commit
927944810e
@ -18,6 +18,7 @@
|
|||||||
#include "video/apple2.h"
|
#include "video/apple2.h"
|
||||||
|
|
||||||
#include "cpu/m6502/m6502.h"
|
#include "cpu/m6502/m6502.h"
|
||||||
|
#include "bus/centronics/ctronics.h"
|
||||||
#include "imagedev/cassette.h"
|
#include "imagedev/cassette.h"
|
||||||
#include "machine/74259.h"
|
#include "machine/74259.h"
|
||||||
#include "machine/bankdev.h"
|
#include "machine/bankdev.h"
|
||||||
@ -48,20 +49,14 @@ public:
|
|||||||
m_ram(*this, RAM_TAG),
|
m_ram(*this, RAM_TAG),
|
||||||
m_screen(*this, "screen"),
|
m_screen(*this, "screen"),
|
||||||
m_video(*this, A2_VIDEO_TAG),
|
m_video(*this, A2_VIDEO_TAG),
|
||||||
m_row0(*this, "ROW0"),
|
m_row(*this, "ROW%u", 0U),
|
||||||
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_kbspecial(*this, "keyb_special"),
|
m_kbspecial(*this, "keyb_special"),
|
||||||
m_sysconfig(*this, "a2_config"),
|
m_sysconfig(*this, "a2_config"),
|
||||||
m_speaker(*this, A2_SPEAKER_TAG),
|
m_speaker(*this, A2_SPEAKER_TAG),
|
||||||
m_cassette(*this, A2_CASSETTE_TAG),
|
m_cassette(*this, A2_CASSETTE_TAG),
|
||||||
m_upperbank(*this, A2_UPPERBANK_TAG),
|
m_upperbank(*this, A2_UPPERBANK_TAG),
|
||||||
m_softlatch(*this, "softlatch")
|
m_softlatch(*this, "softlatch"),
|
||||||
|
m_printer(*this, "printer")
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void tk2000(machine_config &config);
|
void tk2000(machine_config &config);
|
||||||
@ -75,13 +70,14 @@ private:
|
|||||||
required_device<ram_device> m_ram;
|
required_device<ram_device> m_ram;
|
||||||
required_device<screen_device> m_screen;
|
required_device<screen_device> m_screen;
|
||||||
required_device<a2_video_device> m_video;
|
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_kbspecial;
|
||||||
required_ioport m_sysconfig;
|
required_ioport m_sysconfig;
|
||||||
required_device<speaker_sound_device> m_speaker;
|
required_device<speaker_sound_device> m_speaker;
|
||||||
required_device<cassette_image_device> m_cassette;
|
required_device<cassette_image_device> m_cassette;
|
||||||
required_device<address_map_bank_device> m_upperbank;
|
required_device<address_map_bank_device> m_upperbank;
|
||||||
required_device<addressable_latch_device> m_softlatch;
|
required_device<addressable_latch_device> m_softlatch;
|
||||||
|
required_device<centronics_device> m_printer;
|
||||||
|
|
||||||
int m_speaker_state;
|
int m_speaker_state;
|
||||||
int m_cassette_state;
|
int m_cassette_state;
|
||||||
@ -90,6 +86,7 @@ private:
|
|||||||
|
|
||||||
uint8_t *m_ram_ptr;
|
uint8_t *m_ram_ptr;
|
||||||
int m_ram_size;
|
int m_ram_size;
|
||||||
|
bool m_printer_busy;
|
||||||
|
|
||||||
TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt);
|
TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt);
|
||||||
|
|
||||||
@ -97,6 +94,8 @@ private:
|
|||||||
|
|
||||||
uint8_t ram_r(offs_t offset);
|
uint8_t ram_r(offs_t offset);
|
||||||
void ram_w(offs_t offset, uint8_t data);
|
void ram_w(offs_t offset, uint8_t data);
|
||||||
|
|
||||||
|
DECLARE_WRITE_LINE_MEMBER(printer_busy_w);
|
||||||
void kbout_w(uint8_t data);
|
void kbout_w(uint8_t data);
|
||||||
uint8_t kbin_r();
|
uint8_t kbin_r();
|
||||||
uint8_t casout_r();
|
uint8_t casout_r();
|
||||||
@ -108,7 +107,6 @@ private:
|
|||||||
DECLARE_WRITE_LINE_MEMBER(color_w);
|
DECLARE_WRITE_LINE_MEMBER(color_w);
|
||||||
DECLARE_WRITE_LINE_MEMBER(motor_a_w);
|
DECLARE_WRITE_LINE_MEMBER(motor_a_w);
|
||||||
DECLARE_WRITE_LINE_MEMBER(motor_b_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(rom_ram_w);
|
||||||
DECLARE_WRITE_LINE_MEMBER(ctrl_key_w);
|
DECLARE_WRITE_LINE_MEMBER(ctrl_key_w);
|
||||||
uint8_t c080_r(offs_t offset);
|
uint8_t c080_r(offs_t offset);
|
||||||
@ -134,11 +132,13 @@ void tk2000_state::machine_start()
|
|||||||
m_speaker->level_w(m_speaker_state);
|
m_speaker->level_w(m_speaker_state);
|
||||||
m_cassette_state = 0;
|
m_cassette_state = 0;
|
||||||
m_cassette->output(-1.0f);
|
m_cassette->output(-1.0f);
|
||||||
|
m_printer_busy = false;
|
||||||
|
|
||||||
// setup save states
|
// setup save states
|
||||||
save_item(NAME(m_speaker_state));
|
save_item(NAME(m_speaker_state));
|
||||||
save_item(NAME(m_cassette_state));
|
save_item(NAME(m_cassette_state));
|
||||||
save_item(NAME(m_strobe));
|
save_item(NAME(m_strobe));
|
||||||
|
save_item(NAME(m_printer_busy));
|
||||||
|
|
||||||
// setup video pointers
|
// setup video pointers
|
||||||
m_video->m_ram_ptr = m_ram_ptr;
|
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
|
I/O
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
WRITE_LINE_MEMBER(tk2000_state::printer_busy_w)
|
||||||
|
{
|
||||||
|
m_printer_busy = state;
|
||||||
|
}
|
||||||
|
|
||||||
void tk2000_state::kbout_w(uint8_t data)
|
void tk2000_state::kbout_w(uint8_t data)
|
||||||
{
|
{
|
||||||
// write row mask for keyboard scan
|
// write row mask for keyboard scan
|
||||||
switch (data)
|
m_strobe = 0xff;
|
||||||
{
|
for (int i = 0; i < 8; i++)
|
||||||
case 0:
|
if (BIT(data, i))
|
||||||
break;
|
m_strobe &= m_row[i]->read();
|
||||||
|
|
||||||
case 0x01: m_strobe = m_row0->read(); break;
|
m_printer->write_data0(BIT(data, 0));
|
||||||
case 0x02: m_strobe = m_row1->read(); break;
|
m_printer->write_data1(BIT(data, 1));
|
||||||
case 0x04: m_strobe = m_row2->read(); break;
|
m_printer->write_data2(BIT(data, 2));
|
||||||
case 0x08: m_strobe = m_row3->read(); break;
|
m_printer->write_data3(BIT(data, 3));
|
||||||
case 0x10: m_strobe = m_row4->read(); break;
|
m_printer->write_data4(BIT(data, 4));
|
||||||
case 0x20: m_strobe = m_row5->read(); break;
|
m_printer->write_data5(BIT(data, 5));
|
||||||
case 0x40: m_strobe = m_row6->read(); break;
|
m_printer->write_data6(BIT(data, 6));
|
||||||
case 0x80: m_strobe = m_row7->read(); break;
|
m_printer->write_data7(BIT(data, 7));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tk2000_state::kbin_r()
|
uint8_t tk2000_state::kbin_r()
|
||||||
{
|
{
|
||||||
return m_strobe;
|
return m_strobe | (m_printer_busy ? 0x40 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tk2000_state::casout_r()
|
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)
|
WRITE_LINE_MEMBER(tk2000_state::rom_ram_w)
|
||||||
{
|
{
|
||||||
// 0 = ROM, 1 = RAM
|
// 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<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<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<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<5>().set(FUNC(tk2000_state::rom_ram_w));
|
||||||
m_softlatch->q_out_cb<7>().set(FUNC(tk2000_state::ctrl_key_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);
|
CASSETTE(config, m_cassette);
|
||||||
m_cassette->set_default_state(CASSETTE_STOPPED);
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user