diff --git a/include/dos_inc.h b/include/dos_inc.h index 277387c9..9f8590e2 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -627,6 +627,7 @@ struct DOS_Block { bool breakcheck; bool echo; // if set to true dev_con::read will echo input bool direct_output; + bool internal_output; struct { RealPt mediaid; RealPt tempdta; diff --git a/src/dos/dev_con.h b/src/dos/dev_con.h index 5f762d1c..26c4dd63 100644 --- a/src/dos/dev_con.h +++ b/src/dos/dev_con.h @@ -30,11 +30,12 @@ public: bool Write(Bit8u * data,Bit16u * size); bool Seek(Bit32u * pos,Bit32u type); bool Close(); - void ClearAnsi(void); Bit16u GetInformation(void); bool ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return false;} bool WriteToControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retcode){return false;} private: + void ClearAnsi(void); + void Output(Bit8u chr); Bit8u readcache; Bit8u lastwrite; struct ansi { /* should create a constructor, which would fill them with the appropriate values */ @@ -132,18 +133,15 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) { /* expand tab if not direct output */ page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); do { - INT10_TeletypeOutputAttr(' ',ansi.enabled?ansi.attr:7,true); + Output(' '); 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')) { - INT10_TeletypeOutputAttr('\r',ansi.enabled?ansi.attr:7,true); - } - /* use ansi attribute if ansi is enabled, otherwise use DOS default attribute*/ - INT10_TeletypeOutputAttr(data[count],ansi.enabled?ansi.attr:7,true); + if((data[count] == '\n') && (lastwrite != '\r')) Output('\r'); + Output(data[count]); lastwrite = data[count++]; continue; } @@ -168,6 +166,7 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) { continue; } /*ansi.esc and ansi.sci are true */ + if (!dos.internal_output) ansi.enabled=true; page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); switch(data[count]){ case '0': @@ -187,11 +186,9 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) { break; case 'm': /* SGR */ for(i=0;i<=ansi.numberofarg;i++){ - ansi.enabled=true; switch(ansi.data[i]){ case 0: /* normal */ ansi.attr=0x07;//Real ansi does this as well. (should do current defaults) - ansi.enabled=false; break; case 1: /* bold mode on*/ ansi.attr|=0x08; @@ -429,3 +426,19 @@ void device_CON::ClearAnsi(void){ ansi.sci=false; ansi.numberofarg=0; } + +void device_CON::Output(Bit8u chr) { + if (dos.internal_output || ansi.enabled) { + if (CurMode->type==M_TEXT) { + Bit8u page=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); + Bit8u col=CURSOR_POS_COL(page); + Bit8u row=CURSOR_POS_ROW(page); + BIOS_NCOLS;BIOS_NROWS; + if (nrows==row+1 && (chr=='\n' || (ncols==col+1 && chr!='\r' && chr!=8 && chr!=7))) { + INT10_ScrollWindow(0,0,(Bit8u)(nrows-1),(Bit8u)(ncols-1),-1,ansi.attr,page); + INT10_SetCursorPos(row-1,col,page); + } + } + INT10_TeletypeOutputAttr(chr,ansi.attr,true); + } else INT10_TeletypeOutput(chr,7); + } diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 19cf3187..e4826165 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -1240,6 +1240,7 @@ public: dos.version.major=5; dos.version.minor=0; dos.direct_output=false; + dos.internal_output=false; } ~DOS(){ for (Bit16u i=0;i