⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tty.c

📁 raywill写的操作系统内核
💻 C
字号:
#include <maray/tty.h>


#define TAB_SIZE 8
#define thisline(vp) ((vp -VIDMEM)%80)
#define thisrow(vp)	((vp -VIDMEM)/80)

unsigned short* const VIDMEM = ((unsigned short*) 0xB8000);

static void clear( void );

unsigned short * vp;

void init_tty(void)
{
	vp=VIDMEM;
	clear();
}

void clrscr(void)
{
	clear();
}

void getxy(int *x,int  *y)
{
	*x=thisline(vp);
	*y=thisrow(vp);
}
void gotoxy(int x,int y)
{
	if(y<0||y>24||x<0||x>79)
		return;
	vp=VIDMEM+y*80+x;
}

static void clear( void )
{
    int i;
    for (i = 0; i < 80 * 25 ; i++)
        *vp++ = 0;
		vp = VIDMEM;
}



void print( const char* str )
{
    if( vp>=VIDMEM+80*25 )
    	{
    		clear();
    		vp=VIDMEM	;
    	}
    while (*str != '\0')
    {
        if(*str=='\n')
       	 	{
        		vp=vp + 80 - (vp -VIDMEM) % 80;
        		str++;
        		continue;
        	}
        if(*str=='\t')
        	{
        		vp=vp+TAB_SIZE-thisline(vp)%TAB_SIZE;
        		str++;
        		continue;	
        	}
        *vp++ = (0x0600 | ((unsigned short) *str++));
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -