fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

dos: Fix reading from a tty (int 0x21/0x3f)

+23 -3
+23 -3
src/arch/dos/int21.c
··· 771 771 int int21_fct_3f (dos_t *sim) 772 772 { 773 773 int c; 774 + int tty, lf; 774 775 unsigned i, cnt; 775 776 unsigned short seg, ofs; 776 777 FILE *fp; ··· 779 780 return (int21_ret (sim, 1, 6)); 780 781 } 781 782 783 + tty = isatty (fileno (fp)); 784 + 782 785 cnt = e86_get_cx (&sim->cpu); 783 786 seg = e86_get_ds (&sim->cpu); 784 787 ofs = e86_get_dx (&sim->cpu); 785 788 789 + lf = 0; 790 + 786 791 for (i = 0; i < cnt; i++) { 787 - if ((c = fgetc (fp)) == EOF) { 788 - break; 792 + if (lf) { 793 + c = 0x0a; 794 + lf = 0; 795 + } 796 + else { 797 + if ((c = fgetc (fp)) == EOF) { 798 + break; 799 + } 800 + 801 + if (tty && (c == 0x0a)) { 802 + c = 0x0d; 803 + lf = 1; 804 + } 789 805 } 790 806 791 807 sim_set_uint8 (sim, seg, ofs, c); 808 + ofs = (ofs + 1) & 0xffff; 792 809 793 - ofs = (ofs + 1) & 0xffff; 810 + if (tty && (c == 0x0a)) { 811 + i += 1; 812 + break; 813 + } 794 814 } 795 815 796 816 int21_ret (sim, 0, i);