First post, by lucky7456969
lucky7456969
Offline
Rank
Oldbie
- Rank
- Oldbie
Hi,
I am working on the ansi patch now.
But I am using dosbox 0.74 source which doesn't support the chinese system etin3
However, my idea was to create a variable like
bool useAnsi;
When I enable it (either by command prompt or config file)
I bypass the attribute part at device_CON::Write
and dump raw data to the console
But i need ykhwong build now, I can compile it, but cannot run it due to System instability problem
bool device_CON::Write(Bit8u * data,Bit16u * size) {Bit16u count=0;Bitu i;Bit8u col,row;Bit8u tempdata;if (ansi.useAnsi) // Optionally turn on Ansi [By Jacky Luk]{while (*size>count) {if (!ansi.esc){if(data[count]=='\033') {/*clear the datastructure */ClearAnsi();/* start the sequence */ansi.esc=true;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.attr,ansi.enabled);/* pass attribute only if ansi is enabled */INT10_TeletypeOutputAttr(data[count],ansi.attr,ansi.enabled);lastwrite = data[count++];continue;}}if(!ansi.sci){switch(data[count]){case '[':ansi.sci=true;break;case '7': /* save cursor pos + attr */case '8': /* restore this (Wonder if this is actually used) */case 'D':/* scrolling DOWN*/case 'M':/* scrolling UP*/default:LOG(LOG_IOCTL,LOG_NORMAL)("ANSI: unknown char %c after a esc",data[count]); /*prob () */ClearAnsi();break;}count++;continue;}/*ansi.esc and ansi.sci are true */Bit8u page = real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE);switch(data[count]){case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9':ansi.data[ansi.numberofarg]=10*ansi.data[ansi.numberofarg]+(data[count]-'0');break;case ';': /* till a max of NUMBER_ANSI_DATA */
ansi.numberofarg++;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;break;case 4: /* underline */LOG(LOG_IOCTL,LOG_NORMAL)("ANSI:no support for underline yet");break;case 5: /* blinking */ansi.attr|=0x80;break;case 7: /* reverse */ansi.attr=0x70;//Just like real ansi. (should do use current colors reversed)break;case 30: /* fg color black */ansi.attr&=0xf8;ansi.attr|=0x0;break;case 31: /* fg color red */ansi.attr&=0xf8;ansi.attr|=0x4;break;case 32: /* fg color green */ansi.attr&=0xf8;ansi.attr|=0x2;break;case 33: /* fg color yellow */ansi.attr&=0xf8;ansi.attr|=0x6;break;case 34: /* fg color blue */ansi.attr&=0xf8;ansi.attr|=0x1;break;case 35: /* fg color magenta */ansi.attr&=0xf8;ansi.attr|=0x5;break;case 36: /* fg color cyan */ansi.attr&=0xf8;ansi.attr|=0x3;break;case 37: /* fg color white */ansi.attr&=0xf8;ansi.attr|=0x7;break;case 40:ansi.attr&=0x8f;ansi.attr|=0x0;break;case 41:ansi.attr&=0x8f;ansi.attr|=0x40;break;case 42:ansi.attr&=0x8f;ansi.attr|=0x20;break;case 43:ansi.attr&=0x8f;ansi.attr|=0x60;break;case 44:ansi.attr&=0x8f;ansi.attr|=0x10;break;case 45:ansi.attr&=0x8f;ansi.attr|=0x50;break;case 46:ansi.attr&=0x8f;ansi.attr|=0x30;break;case 47:ansi.attr&=0x8f;ansi.attr|=0x70;break;default:break;}}ClearAnsi();break;case 'f':case 'H':/* Cursor Pos*/if(!ansi.warned) { //Inform the debugger that ansi is used.ansi.warned = true;LOG(LOG_IOCTL,LOG_WARN)("ANSI SEQUENCES USED");}/* 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;INT10_SetCursorPos(--(ansi.data[0]),--(ansi.data[1]),page); /*ansi=1 based, int10 is 0 based */ClearAnsi();break;/* cursor up down and forward and backward only change the row or the col not both */case 'A': /* cursor up*/col=CURSOR_POS_COL(page) ;row=CURSOR_POS_ROW(page) ;tempdata = (ansi.data[0]? ansi.data[0] : 1);if(tempdata > row) { row=0; }else { row-=tempdata;}INT10_SetCursorPos(row,col,page);ClearAnsi();break;case 'B': /*cursor Down */col=CURSOR_POS_COL(page) ;row=CURSOR_POS_ROW(page) ;tempdata = (ansi.data[0]? ansi.data[0] : 1);if(tempdata + static_cast<Bitu>(row) >= ansi.nrows){ row = ansi.nrows - 1;}else { row += tempdata; }INT10_SetCursorPos(row,col,page);ClearAnsi();break;case 'C': /*cursor forward */col=CURSOR_POS_COL(page);row=CURSOR_POS_ROW(page);tempdata=(ansi.data[0]? ansi.data[0] : 1);if(tempdata + static_cast<Bitu>(col) >= ansi.ncols){ col = ansi.ncols - 1;}else { col += tempdata;}INT10_SetCursorPos(row,col,page);ClearAnsi();break;case 'D': /*Cursor Backward */col=CURSOR_POS_COL(page);row=CURSOR_POS_ROW(page);tempdata=(ansi.data[0]? ansi.data[0] : 1);if(tempdata > col) {col = 0;}else { col -= tempdata;}INT10_SetCursorPos(row,col,page);ClearAnsi();break;case 'J': /*erase screen and move cursor home*/if(ansi.data[0]==0) ansi.data[0]=2;if(ansi.data[0]!=2) {/* every version behaves like type 2 */LOG(LOG_IOCTL,LOG_NORMAL)("ANSI: esc[%dJ called : not supported handling as 2",ansi.data[0]);}INT10_ScrollWindow(0,0,255,255,0,ansi.attr,page);ClearAnsi();INT10_SetCursorPos(0,0,page);break;case 'h': /* SET MODE (if code =7 enable linewrap) */case 'I': /* RESET MODE */LOG(LOG_IOCTL,LOG_NORMAL)("ANSI: set/reset mode called(not supported)");ClearAnsi();break;case 'u': /* Restore Cursor Pos */INT10_SetCursorPos(ansi.saverow,ansi.savecol,page);ClearAnsi();break;case 's': /* SAVE CURSOR POS */ansi.savecol=CURSOR_POS_COL(page);ansi.saverow=CURSOR_POS_ROW(page);ClearAnsi();break;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);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);ClearAnsi();break;case 'l':/* (if code =7) disable linewrap */case 'p':/* reassign keys (needs strings) */case 'i':/* printer stuff */default:LOG(LOG_IOCTL,LOG_NORMAL)("ANSI: unhandled char %c in esc[",data[count]);ClearAnsi();break;}count++;}*size=count;}else{// Output Raw Data (ususally one character) to consoleINT10_TeletypeOutputAttr(data[count],ansi.attr,ansi.enabled);}return true;}
Dosbox becomes very slow, and i am unsure I am using the right function or not. This is what I get from the debugger.
What are your comments?
Here is the result:
Last edited by lucky7456969 on 2012-08-20, 11:19. Edited 2 times in total.