Improve internal ANSI support to adapt to currently displayed columns and rows. Fixes original Infocom interpreters when using something other than 80x25.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3948
This commit is contained in:
parent
2a1ae6fb9c
commit
53a38b773a
1 changed files with 17 additions and 14 deletions
|
@ -44,8 +44,6 @@ private:
|
|||
Bit8u attr;
|
||||
Bit8u data[NUMBER_ANSI_DATA];
|
||||
Bit8u numberofarg;
|
||||
Bit16u nrows;
|
||||
Bit16u ncols;
|
||||
Bit8s savecol;
|
||||
Bit8s saverow;
|
||||
bool warned;
|
||||
|
@ -117,6 +115,7 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) {
|
|||
Bit16u count=0;
|
||||
Bitu i;
|
||||
Bit8u col,row;
|
||||
Bit16u ncols,nrows;
|
||||
Bit8u tempdata;
|
||||
while (*size>count) {
|
||||
if (!ansi.esc){
|
||||
|
@ -273,11 +272,13 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) {
|
|||
ansi.warned = true;
|
||||
LOG(LOG_IOCTL,LOG_WARN)("ANSI SEQUENCES USED");
|
||||
}
|
||||
ncols = real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
|
||||
nrows = real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS) + 1;
|
||||
/* Turn them into positions that are on the screen */
|
||||
if(ansi.data[0] == 0) ansi.data[0] = 1;
|
||||
if(ansi.data[1] == 0) ansi.data[1] = 1;
|
||||
if(ansi.data[0] > ansi.nrows) ansi.data[0] = (Bit8u)ansi.nrows;
|
||||
if(ansi.data[1] > ansi.ncols) ansi.data[1] = (Bit8u)ansi.ncols;
|
||||
if(ansi.data[0] > nrows) ansi.data[0] = (Bit8u)nrows;
|
||||
if(ansi.data[1] > ncols) ansi.data[1] = (Bit8u)ncols;
|
||||
INT10_SetCursorPos(--(ansi.data[0]),--(ansi.data[1]),page); /*ansi=1 based, int10 is 0 based */
|
||||
ClearAnsi();
|
||||
break;
|
||||
|
@ -294,9 +295,10 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) {
|
|||
case 'B': /*cursor Down */
|
||||
col=CURSOR_POS_COL(page) ;
|
||||
row=CURSOR_POS_ROW(page) ;
|
||||
nrows = real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS) + 1;
|
||||
tempdata = (ansi.data[0]? ansi.data[0] : 1);
|
||||
if(tempdata + static_cast<Bitu>(row) >= ansi.nrows)
|
||||
{ row = ansi.nrows - 1;}
|
||||
if(tempdata + static_cast<Bitu>(row) >= nrows)
|
||||
{ row = nrows - 1;}
|
||||
else { row += tempdata; }
|
||||
INT10_SetCursorPos(row,col,page);
|
||||
ClearAnsi();
|
||||
|
@ -304,9 +306,10 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) {
|
|||
case 'C': /*cursor forward */
|
||||
col=CURSOR_POS_COL(page);
|
||||
row=CURSOR_POS_ROW(page);
|
||||
ncols = real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
|
||||
tempdata=(ansi.data[0]? ansi.data[0] : 1);
|
||||
if(tempdata + static_cast<Bitu>(col) >= ansi.ncols)
|
||||
{ col = ansi.ncols - 1;}
|
||||
if(tempdata + static_cast<Bitu>(col) >= ncols)
|
||||
{ col = ncols - 1;}
|
||||
else { col += tempdata;}
|
||||
INT10_SetCursorPos(row,col,page);
|
||||
ClearAnsi();
|
||||
|
@ -346,15 +349,17 @@ bool device_CON::Write(Bit8u * data,Bit16u * size) {
|
|||
case 'K': /* erase till end of line (don't touch cursor) */
|
||||
col = CURSOR_POS_COL(page);
|
||||
row = CURSOR_POS_ROW(page);
|
||||
INT10_WriteChar(' ',ansi.attr,page,ansi.ncols-col,true); //Use this one to prevent scrolling when end of screen is reached
|
||||
//for(i = col;i<(Bitu) ansi.ncols; i++) INT10_TeletypeOutputAttr(' ',ansi.attr,true);
|
||||
ncols = real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
|
||||
INT10_WriteChar(' ',ansi.attr,page,ncols-col,true); //Use this one to prevent scrolling when end of screen is reached
|
||||
//for(i = col;i<(Bitu) ncols; i++) INT10_TeletypeOutputAttr(' ',ansi.attr,true);
|
||||
INT10_SetCursorPos(row,col,page);
|
||||
ClearAnsi();
|
||||
break;
|
||||
case 'M': /* delete line (NANSI) */
|
||||
col = CURSOR_POS_COL(page);
|
||||
row = CURSOR_POS_ROW(page);
|
||||
INT10_ScrollWindow(row,0,ansi.nrows-1,ansi.ncols-1,ansi.data[0]? -ansi.data[0] : -1,ansi.attr,0xFF);
|
||||
ncols = real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
|
||||
nrows = real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS) + 1;
|
||||
INT10_ScrollWindow(row,0,nrows-1,ncols-1,ansi.data[0]? -ansi.data[0] : -1,ansi.attr,0xFF);
|
||||
ClearAnsi();
|
||||
break;
|
||||
case 'l':/* (if code =7) disable linewrap */
|
||||
|
@ -403,8 +408,6 @@ device_CON::device_CON() {
|
|||
lastwrite=0;
|
||||
ansi.enabled=false;
|
||||
ansi.attr=0x7;
|
||||
ansi.ncols=real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS); //should be updated once set/reset mode is implemented
|
||||
ansi.nrows=real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS) + 1;
|
||||
ansi.saverow=0;
|
||||
ansi.savecol=0;
|
||||
ansi.warned=false;
|
||||
|
|
Loading…
Add table
Reference in a new issue