1
1
/* i1620_lp.c: IBM 1443 line printer simulator
2
2
3
- Copyright (c) 2002-2017 , Robert M. Supnik
3
+ Copyright (c) 2002-2021 , Robert M. Supnik
4
4
5
5
Permission is hereby granted, free of charge, to any person obtaining a
6
6
copy of this software and associated documentation files (the "Software"),
25
25
26
26
lpt 1443 line printer
27
27
28
+ 10-Jun-21 RMS Removed use of ftell for pipe compatibility
28
29
15-Jun-17 RMS Fixed K constants and print-no-spacing (Tom McBride)
29
30
Added option to emulate form feed with newlines
30
31
31-Jan-15 TFM Fixed various problems ... see comments in code
@@ -279,7 +280,7 @@ return sta;
279
280
280
281
t_stat lpt_print (uint32 flag )
281
282
{
282
- int32 i ;
283
+ int32 i , cc ;
283
284
284
285
if ((lpt_unit .flags & UNIT_ATT ) == 0 ) { /* not attached? */
285
286
ind [IN_PRCHK ] = 1 ; /* pri check */
@@ -292,16 +293,19 @@ while ((lpt_bptr > 0) && (lpt_buf[lpt_bptr - 1] == ' '))
292
293
lpt_buf [-- lpt_bptr ] = 0 ; /* trim buffer */
293
294
if (lpt_bptr != 0 ) { /* any line? */
294
295
fputs (lpt_buf , lpt_unit .fileref ); /* print */
295
- if ((flag & 1 ) != 0 ) /* no space? */
296
+ cc = strlen (lpt_buf );
297
+ if ((flag & 1 ) != 0 ) { /* no space? */
296
298
fputc ('\r' , lpt_unit .fileref ); /* bare return */
297
- lpt_unit .pos = ftell (lpt_unit .fileref ); /* update pos */
299
+ cc ++ ;
300
+ }
298
301
lpt_buf_init (); /* reinit buf */
299
302
if (ferror (lpt_unit .fileref )) { /* error? */
300
303
ind [IN_PRCHK ] = 1 ; /* pri check */
301
304
sim_perror ("LPT I/O error" );
302
305
clearerr (lpt_unit .fileref );
303
306
return SCPE_IOERR ;
304
307
}
308
+ lpt_unit .pos = lpt_unit .pos + (t_addr )cc ; /* update pos */
305
309
}
306
310
if ((flag & 1 ) == 0 ) /* spacing? */
307
311
return lpt_spcop (lpt_savctrl ); /* execute */
@@ -336,17 +340,19 @@ return STOP_CCT; /* runaway channel */
336
340
337
341
t_stat lpt_space (int32 count , int32 sflag )
338
342
{
339
- int32 i ;
343
+ int32 i , cc ;
340
344
341
345
cct_ptr = (cct_ptr + count ) % cct_lnt ; /* adv cct, mod lnt */
342
346
if (sflag && CHP (0 , cct [cct_ptr ]) && /* skip, top of form, */
343
- ((lpt_unit .flags & UNIT_FF ) != 0 )) /* and use form feeds? */
347
+ ((lpt_unit .flags & UNIT_FF ) != 0 )) { /* and use form feeds? */
344
348
fputs ("\n\f" , lpt_unit .fileref ); /* nl, ff */
349
+ cc = 2 ;
350
+ }
345
351
else {
346
352
for (i = 0 ; i < count ; i ++ ) /* count lines */
347
353
fputc ('\n' , lpt_unit .fileref );
354
+ cc = count ;
348
355
}
349
- lpt_unit .pos = ftell (lpt_unit .fileref ); /* update position */
350
356
ind [IN_PRCH9 ] = CHP (9 , cct [cct_ptr ]) != 0 ; /* set indicators */
351
357
ind [IN_PRCH12 ] = CHP (12 , cct [cct_ptr ]) != 0 ;
352
358
if (ferror (lpt_unit .fileref )) { /* error? */
@@ -355,6 +361,7 @@ if (ferror (lpt_unit.fileref)) { /* error? */
355
361
clearerr (lpt_unit .fileref );
356
362
return SCPE_IOERR ;
357
363
}
364
+ lpt_unit .pos = lpt_unit .pos + (t_addr )cc ; /* update position */
358
365
ind [IN_PRBSY ] = 1 ; /* print busy */
359
366
sim_activate (& lpt_unit , lpt_unit .wait ); /* start timer */
360
367
return SCPE_OK ;
0 commit comments