From 64a04b99853ed12137d6fa2ee0349e68bcd7a749 Mon Sep 17 00:00:00 2001 From: ripsaw8080 Date: Mon, 23 May 2016 11:33:09 +0000 Subject: [PATCH] Be more compatible by converting tabs to spaces in the DOS console device rather than in the video BIOS teletype function. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3983 --- include/dos_inc.h | 1 + src/dos/dev_con.h | 14 ++++++++++++-- src/dos/dos.cpp | 8 ++++++-- src/ints/int10_char.cpp | 7 ------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/dos_inc.h b/include/dos_inc.h index a3729e26..3782d34e 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -626,6 +626,7 @@ struct DOS_Block { bool verify; bool breakcheck; bool echo; // if set to true dev_con::read will echo input + bool direct_output; struct { RealPt mediaid; RealPt tempdta; diff --git a/src/dos/dev_con.h b/src/dos/dev_con.h index 9368c49c..3cf0cb13 100644 --- a/src/dos/dev_con.h +++ b/src/dos/dev_con.h @@ -115,7 +115,7 @@ bool device_CON::Read(Bit8u * data,Bit16u * size) { bool device_CON::Write(Bit8u * data,Bit16u * size) { Bit16u count=0; Bitu i; - Bit8u col,row; + Bit8u col,row,page; Bit16u ncols,nrows; Bit8u tempdata; INT10_SetCurMode(); @@ -128,6 +128,16 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) { ansi.esc=true; count++; continue; + } else if(data[count] == '\t' && !dos.direct_output) { + /* expand tab if not direct output */ + page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); + do { + if(ansi.enabled) INT10_TeletypeOutputAttr(' ',ansi.attr,true); + else INT10_TeletypeOutput(' ',7); + col=CURSOR_POS_COL(page); + } while(col%8); + lastwrite = data[count++]; + continue; } else { /* Some sort of "hack" now that '\n' doesn't set col to 0 (int10_char.cpp old chessgame) */ if((data[count] == '\n') && (lastwrite != '\r')) { @@ -161,7 +171,7 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) { continue; } /*ansi.esc and ansi.sci are true */ - Bit8u page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); + page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); switch(data[count]){ case '0': case '1': diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index a421fe07..c35f6edf 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -133,7 +133,7 @@ static Bitu DOS_21Handler(void) { Bit8u c=reg_dl;Bit16u n=1; DOS_WriteFile(STDOUT,&c,&n); //Not in the official specs, but happens nonetheless. (last written character) - reg_al = c;// reg_al=(c==9)?0x20:c; //Officially: tab to spaces + reg_al=(c==9)?0x20:c; //strangely, tab conversion to spaces is reflected here } break; case 0x03: /* Read character from STDAUX */ @@ -184,8 +184,10 @@ static Bitu DOS_21Handler(void) { default: { Bit8u c = reg_dl;Bit16u n = 1; + dos.direct_output=true; DOS_WriteFile(STDOUT,&c,&n); - reg_al = reg_dl; + dos.direct_output=false; + reg_al=c; } break; }; @@ -211,6 +213,7 @@ static Bitu DOS_21Handler(void) { while ((c=mem_readb(buf++))!='$') { DOS_WriteFile(STDOUT,&c,&n); } + reg_al=c; } break; case 0x0a: /* Buffered Input */ @@ -1236,6 +1239,7 @@ public: dos.version.major=5; dos.version.minor=0; + dos.direct_output=false; } ~DOS(){ for (Bit16u i=0;i