1
/* nova_lp.c: NOVA line printer simulator
3
Copyright (c) 1993-1997,
4
Robert M Supnik, Digital Equipment Corporation
5
Commercial use prohibited
10
#include "nova_defs.h"
12
extern int32 int_req, dev_busy, dev_done, dev_disable;
13
int32 lpt_stopioe = 0; /* stop on error */
14
t_stat lpt_svc (UNIT *uptr);
15
t_stat lpt_reset (DEVICE *dptr);
16
extern t_stat sim_activate (UNIT *uptr, int32 delay);
17
extern t_stat sim_cancel (UNIT *uptr);
19
/* LPT data structures
21
lpt_dev LPT device descriptor
22
lpt_unit LPT unit descriptor
23
lpt_reg LPT register list
27
UDATA (&lpt_svc, UNIT_SEQ+UNIT_ATTABLE, 0), SERIAL_OUT_WAIT };
30
{ ORDATA (BUF, lpt_unit.buf, 8) },
31
{ FLDATA (BUSY, dev_busy, INT_V_LPT) },
32
{ FLDATA (DONE, dev_done, INT_V_LPT) },
33
{ FLDATA (DISABLE, dev_disable, INT_V_LPT) },
34
{ FLDATA (INT, int_req, INT_V_LPT) },
35
{ DRDATA (POS, lpt_unit.pos, 31), PV_LEFT },
36
{ DRDATA (TIME, lpt_unit.wait, 24), PV_LEFT },
37
{ FLDATA (STOP_IOE, lpt_stopioe, 0) },
41
"LPT", &lpt_unit, lpt_reg, NULL,
43
NULL, NULL, &lpt_reset,
48
int32 lpt (int32 pulse, int32 code, int32 AC)
51
if (code == ioDOA) lpt_unit.buf = AC & 0177;
52
switch (pulse) { /* decode IR<8:9> */
53
case iopS: /* start */
54
dev_busy = dev_busy | INT_LPT; /* set busy */
55
dev_done = dev_done & ~INT_LPT; /* clear done, int */
56
int_req = int_req & ~INT_LPT;
57
if ((lpt_unit.buf != 015) && (lpt_unit.buf != 014) &&
58
(lpt_unit.buf != 012))
59
return (lpt_svc (&lpt_unit) << IOT_V_REASON);
60
sim_activate (&lpt_unit, lpt_unit.wait);
62
case iopC: /* clear */
63
dev_busy = dev_busy & ~INT_LPT; /* clear busy */
64
dev_done = dev_done & ~INT_LPT; /* clear done, int */
65
int_req = int_req & ~INT_LPT;
66
sim_cancel (&lpt_unit); /* deactivate unit */
67
break; } /* end switch */
73
t_stat lpt_svc (UNIT *uptr)
75
dev_busy = dev_busy & ~INT_LPT; /* clear busy */
76
dev_done = dev_done | INT_LPT; /* set done */
77
int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable);
78
if ((lpt_unit.flags & UNIT_ATT) == 0) /* attached? */
79
return IORETURN (lpt_stopioe, SCPE_UNATT);
80
if (putc (lpt_unit.buf, lpt_unit.fileref) == EOF) {
81
perror ("LPT I/O error");
82
clearerr (lpt_unit.fileref);
84
lpt_unit.pos = ftell (lpt_unit.fileref);
90
t_stat lpt_reset (DEVICE *dptr)
93
dev_busy = dev_busy & ~INT_LPT; /* clear busy */
94
dev_done = dev_done & ~INT_LPT; /* clear done, int */
95
int_req = int_req & ~INT_LPT;
96
sim_cancel (&lpt_unit); /* deactivate unit */