Skip to content

Commit 417219e

Browse files
committed
I1620: Upgrade lpt to sim_pdflpt
1 parent 9ac2ca4 commit 417219e

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

I1620/i1620_lp.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
#include "i1620_defs.h"
35+
#include "sim_pdflpt.h"
3536

3637
#define LPT_BSIZE 197 /* buffer size */
3738

@@ -70,7 +71,7 @@ t_stat lpt_space (int32 lines, int32 lflag);
7071
*/
7172

7273
UNIT lpt_unit = {
73-
UDATA (&lpt_svc, UNIT_SEQ+UNIT_ATTABLE+UNIT_TEXT, 50)
74+
UDATA (&lpt_svc, UNIT_SEQ+UNIT_ATTABLE, 50)
7475
};
7576

7677
REG lpt_reg[] = {
@@ -92,8 +93,11 @@ DEVICE lpt_dev = {
9293
"LPT", &lpt_unit, lpt_reg, NULL,
9394
1, 10, 31, 1, 8, 7,
9495
NULL, NULL, &lpt_reset,
95-
NULL, &lpt_attach, NULL
96-
};
96+
NULL, &lpt_attach, &pdflpt_detach,
97+
NULL, 0, 0,
98+
NULL, NULL, NULL,
99+
&pdflpt_help, &pdflpt_attach_help,
100+
};
97101

98102
/* Data tables */
99103

@@ -255,13 +259,13 @@ for (i = LPT_WIDTH; i <= LPT_BSIZE; i++) /* clear unprintable */
255259
while ((lpt_bptr > 0) && (lpt_buf[lpt_bptr - 1] == ' '))
256260
lpt_buf[--lpt_bptr] = 0; /* trim buffer */
257261
if (lpt_bptr) { /* any line? */
258-
fputs (lpt_buf, lpt_unit.fileref); /* print */
259-
lpt_unit.pos = ftell (lpt_unit.fileref); /* update pos */
262+
pdflpt_puts (&lpt_unit, lpt_buf); /* print */
263+
lpt_unit.pos = pdflpt_where (&lpt_unit, NULL); /* update pos */
260264
lpt_buf_init (); /* reinit buf */
261-
if (ferror (lpt_unit.fileref)) { /* error? */
265+
if (pdflpt_error (&lpt_unit)) { /* error? */
262266
ind[IN_PRCHK] = ind[IN_WRCHK] = 1; /* wr, pri check */
263-
perror ("LPT I/O error");
264-
clearerr (lpt_unit.fileref);
267+
pdflpt_perror (&lpt_unit, "LPT I/O error");
268+
pdflpt_clearerr (&lpt_unit);
265269
return SCPE_IOERR;
266270
}
267271
}
@@ -301,18 +305,18 @@ int32 i;
301305

302306
cct_ptr = (cct_ptr + count) % cct_lnt; /* adv cct, mod lnt */
303307
if (sflag && CHP (0, cct[cct_ptr])) /* skip, top of form? */
304-
fputs ("\n\f", lpt_unit.fileref); /* nl, ff */
308+
pdflpt_puts (&lpt_unit, "\n\f"); /* nl, ff */
305309
else {
306310
for (i = 0; i < count; i++) /* count lines */
307-
fputc ('\n', lpt_unit.fileref);
311+
pdflpt_putc (&lpt_unit, '\n');
308312
}
309-
lpt_unit.pos = ftell (lpt_unit.fileref); /* update position */
313+
lpt_unit.pos = pdflpt_where (&lpt_unit, NULL); /* update position */
310314
ind[IN_PRCH9] = CHP (9, cct[cct_ptr]) != 0; /* set indicators */
311315
ind[IN_PRCH12] = CHP (12, cct[cct_ptr]) != 0;
312-
if (ferror (lpt_unit.fileref)) { /* error? */
316+
if (pdflpt_error (&lpt_unit)) { /* error? */
313317
ind[IN_PRCHK] = ind[IN_WRCHK] = 1; /* wr, pri check */
314-
perror ("LPT I/O error");
315-
clearerr (lpt_unit.fileref);
318+
pdflpt_perror (&lpt_unit, "LPT I/O error");
319+
pdflpt_clearerr (&lpt_unit);
316320
return SCPE_IOERR;
317321
}
318322
return SCPE_OK;
@@ -342,11 +346,15 @@ return;
342346

343347
t_stat lpt_reset (DEVICE *dptr)
344348
{
349+
char tbuf[sizeof ("columns=999")];
345350
lpt_buf_init (); /* clear buffer */
346351
cct_ptr = 0; /* clear cct ptr */
347352
lpt_savctrl = 0x61; /* clear cct action */
348353
ind[IN_PRCHK] = ind[IN_PRBSY] = 0; /* clear indicators */
349354
ind[IN_PRCH9] = ind[IN_PRCH12] = 0;
355+
pdflpt_reset (&lpt_unit);
356+
sprintf (tbuf, "columns=%u", LPT_WIDTH);
357+
pdflpt_set_defaults (&lpt_unit, tbuf);
350358
return SCPE_OK;
351359
}
352360

@@ -355,5 +363,5 @@ return SCPE_OK;
355363
t_stat lpt_attach (UNIT *uptr, char *cptr)
356364
{
357365
lpt_reset (&lpt_dev);
358-
return attach_unit (uptr, cptr);
366+
return pdflpt_attach (uptr, cptr);
359367
}

0 commit comments

Comments
 (0)