X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fdrv%2Fvterm.c;h=5545da77b29db7f2c343c81313098f5290713909;hb=1c821df6e9a345c41e0b7e5b71544ec6defb7faf;hp=b73e8dea1e466efba7990e69b9668c84b3cb9d52;hpb=85eb17b306404571aa39596946c87ad9bb1d9d13;p=tpg%2Facess2.git diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index b73e8dea..5545da77 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -24,8 +24,6 @@ #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 480 #define DEFAULT_SCROLLBACK 2 // 2 Screens of text + current screen -#define TEXTTERM_WIDTH (BOOT_WIDTH/8) -#define TEXTTERM_HEIGHT (BOOT_WIDTH/16) #define DEFAULT_COLOUR (VT_COL_BLACK|(0xAAA<<16)) #define VT_FLAG_HIDECSR 0x01 @@ -390,26 +388,36 @@ Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { if( giVT_RealWidth > term->Width || giVT_RealHeight > term->Height ) { - #if 0 - int x, y, h; + int x, y, w, h; x = Offset/4; y = x / term->Width; x %= term->Width; w = Length/4+x; h = w / term->Width; w %= term->Width; + // Center + x += (giVT_RealWidth - term->Width) / 2; + y += (giVT_RealHeight - term->Height) / 2; while(h--) { VFS_WriteAt( giVT_OutputDevHandle, - (x+y*term->RealWidth)*4, + (x + y * giVT_RealWidth)*4, term->Width * 4, Buffer ); - Buffer = (void*)( (Uint)Buffer + term->Width*term->Height*4 ); + Buffer = (void*)( (Uint)Buffer + term->Width*4 ); + y ++; } - #endif return 0; } else { return VFS_WriteAt( giVT_OutputDevHandle, Offset, Length, Buffer ); } } + + case TERM_MODE_2DACCEL: + //case TERM_MODE_3DACCEL: + if( Node->Inode == giVT_CurrentTerminal ) + { + VFS_Write( giVT_OutputDevHandle, Length, Buffer ); + } + break; } return 0; @@ -903,19 +911,23 @@ void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count) { Uint32 val; int i; + + // Iterate for( i = 0; i < Count; i++ ) { - if( Buffer[i] == 0x1B ) // Escape Sequence + // Handle escape sequences + if( Buffer[i] == 0x1B ) { i ++; i += VT_int_ParseEscape(Term, (char*)&Buffer[i]) - 1; continue; } + // Fast check for non UTF-8 if( Buffer[i] < 128 ) // Plain ASCII VT_int_PutChar(Term, Buffer[i]); else { // UTF-8 - i += ReadUTF8(&Buffer[i], &val); + i += ReadUTF8(&Buffer[i], &val) - 1; VT_int_PutChar(Term, val); } } @@ -939,9 +951,7 @@ void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count) void VT_int_PutChar(tVTerm *Term, Uint32 Ch) { int i; - //ENTER("pTerm xCh", Term, Ch); - //LOG("Term = {WritePos:%i, ViewPos:%i}", Term->WritePos, Term->ViewPos); - + switch(Ch) { case '\0': return; // Ignore NULL byte @@ -990,21 +1000,27 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) } // Move Screen + // - Check if we need to scroll the entire scrollback buffer if(Term->WritePos >= Term->Width*Term->Height*(giVT_Scrollback+1)) { int base, i; + + //Debug("Scrolling entire buffer"); + + // Move back by one Term->WritePos -= Term->Width; + // Update the scren VT_int_UpdateScreen( Term, 0 ); // Update view position - base = Term->Width*Term->Height*(giVT_Scrollback-1); - if(Term->ViewPos < base) Term->ViewPos += Term->Width; - if(Term->ViewPos > base) Term->ViewPos = base; + base = Term->Width*Term->Height*(giVT_Scrollback); + if(Term->ViewPos < base) + Term->ViewPos += Term->Width; + if(Term->ViewPos > base) + Term->ViewPos = base; // Scroll terminal cache base = Term->Width*(Term->Height*(giVT_Scrollback+1)-1); - - // Scroll Back memcpy( Term->Text, &Term->Text[Term->Width], @@ -1018,18 +1034,26 @@ void VT_int_PutChar(tVTerm *Term, Uint32 Ch) Term->Text[ base + i ].Colour = Term->CurColour; } - //LOG("Scrolled buffer"); VT_int_ScrollFramebuffer( Term ); VT_int_UpdateScreen( Term, 0 ); } + // Ok, so we only need to scroll the screen else if(Term->WritePos >= Term->ViewPos + Term->Width*Term->Height) { - //LOG("Scrolled screen"); + //Debug("Term->WritePos (%i) >= %i", + // Term->WritePos, + // Term->ViewPos + Term->Width*Term->Height + // ); + //Debug("Scrolling screen only"); + + // Update the last line Term->WritePos -= Term->Width; VT_int_UpdateScreen( Term, 0 ); Term->WritePos += Term->Width; + // Scroll Term->ViewPos += Term->Width; + //Debug("Term->ViewPos = %i", Term->ViewPos); VT_int_ScrollFramebuffer( Term ); VT_int_UpdateScreen( Term, 0 ); } @@ -1050,23 +1074,23 @@ void VT_int_ScrollFramebuffer( tVTerm *Term ) Uint16 SrcX, SrcY; Uint16 W, H; } PACKED buf; + // Only update if this is the current terminal if( Term != gpVT_CurTerm ) return; - // This should only be called in text mode - + // Switch to 2D Command Stream tmp = VIDEO_BUFFMT_2DSTREAM; VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp); + // BLIT from 0,0 to 0,giVT_CharHeight buf.Op = VIDEO_2DOP_BLIT; buf.DstX = 0; buf.DstY = 0; buf.SrcX = 0; buf.SrcY = giVT_CharHeight; buf.W = Term->Width * giVT_CharWidth; buf.H = (Term->Height-1) * giVT_CharHeight; + VFS_WriteAt(giVT_OutputDevHandle, 0, sizeof(buf), &buf); - VFS_WriteAt(giVT_OutputDevHandle, 0, 1+12, &buf); - - // Restore old mode + // Restore old mode (this function is only called during text mode) tmp = VIDEO_BUFFMT_TEXT; VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp); } @@ -1083,21 +1107,18 @@ void VT_int_UpdateScreen( tVTerm *Term, int UpdateAll ) switch( Term->Mode ) { case TERM_MODE_TEXT: + // Re copy the entire screen? if(UpdateAll) { - //LOG("UpdateAll = 1"); - //LOG("VFS_WriteAt(0x%x, 0, %i*sizeof(tVT_Char), &Term->Text[%i])", - // giVT_OutputDevHandle, Term->Width*Term->Height, Term->ViewPos); VFS_WriteAt( giVT_OutputDevHandle, 0, Term->Width*Term->Height*sizeof(tVT_Char), &Term->Text[Term->ViewPos] ); - } else { + } + // Only copy the current line + else { int pos = Term->WritePos - Term->WritePos % Term->Width; - //LOG("UpdateAll = 0"); - //LOG("VFS_WriteAt(0x%x, %i*sizeof(tVT_Char), %i*sizeof(tVT_Char), &Term->Text[%i])", - // giVT_OutputDevHandle, (pos - Term->ViewPos), Term->Width, pos); VFS_WriteAt( giVT_OutputDevHandle, (pos - Term->ViewPos)*sizeof(tVT_Char),