1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/***************************************************************************
IQ151 STAPER (STAndard PERipheral) module emulation
STAPER module includes cables for connect:
- a printer (CONSUL 2112 or 2113)
- a paper tape puncher (DT-105S)
- a paper tape reader (FS-1503)
Currently only the printer is emulated
***************************************************************************/
#include "emu.h"
#include "staper.h"
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
DEFINE_DEVICE_TYPE(IQ151_STAPER, iq151_staper_device, "iq151_staper", "IQ151 STAPER")
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// iq151_staper_device - constructor
//-------------------------------------------------
iq151_staper_device::iq151_staper_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, IQ151_STAPER, tag, owner, clock)
, device_iq151cart_interface(mconfig, *this)
, m_ppi(*this, "ppi8255")
, m_printer(*this, "printer")
, m_printer_timer(nullptr)
, m_ppi_portc(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void iq151_staper_device::device_start()
{
m_printer_timer = timer_alloc(TIMER_PRINTER);
m_printer_timer->reset();
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void iq151_staper_device::device_add_mconfig(machine_config &config)
{
I8255A(config, m_ppi);
m_ppi->in_pa_callback().set(FUNC(iq151_staper_device::ppi_porta_r));
m_ppi->out_pb_callback().set(FUNC(iq151_staper_device::ppi_portb_w));
m_ppi->out_pc_callback().set(FUNC(iq151_staper_device::ppi_portc_w));
PRINTER(config, "printer", 0);
}
//-------------------------------------------------
// device_timer - handler timer events
//-------------------------------------------------
void iq151_staper_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (id == TIMER_PRINTER)
m_ppi->pc2_w(0);
}
//-------------------------------------------------
// IO read
//-------------------------------------------------
void iq151_staper_device::io_read(offs_t offset, uint8_t &data)
{
if (offset >= 0xf8 && offset < 0xfc)
data = m_ppi->read(offset & 0x03);
}
//-------------------------------------------------
// IO write
//-------------------------------------------------
void iq151_staper_device::io_write(offs_t offset, uint8_t data)
{
if (offset >= 0xf8 && offset < 0xfc)
m_ppi->write(offset & 0x03, data);
}
//**************************************************************************
// I8255 interface
//**************************************************************************
READ8_MEMBER( iq151_staper_device::ppi_porta_r )
{
// TODO: paper tape reader input
return 0;
}
WRITE8_MEMBER( iq151_staper_device::ppi_portb_w )
{
if (m_ppi_portc & 0x80)
{
// printer out
m_printer->output(data);
// CONSUL 2112/3 usually print 65/70 cps
m_printer_timer->adjust(attotime::from_msec(15));
}
if (m_ppi_portc & 0x40)
{
// TODO: paper tape puncher out
}
}
WRITE8_MEMBER( iq151_staper_device::ppi_portc_w )
{
/*
x--- ---- printer select
-x-- ---- punchtape select
*/
m_ppi_portc = data;
}
|