//CGA 是 Color Graphics Adapter 的缩写,信号类型为 TTL,最多能显示 16 色,显示卡端的接口为 9 针母插座
void cga_init(void)
{
volatile uint16_t *cp;
uint16_t was;
unsigned pos;
cp = (uint16_t*) (KERNBASE + CGA_BUF);
/*
CGA_BUF: 0xB8000 (物理地址)
为了使地址转换后(-KERNBASE)还是0xB8000,那么就需要+KERNBASE
*/
was = *cp; //保存当前光标所在值
*cp = (uint16_t)0xA55A; // ?? *********
if (*cp != 0xA55A) {
cp = (uint16_t*)(KERNBASE + MONO_BUF);
addr_6845 = MONO_BASE; /* CGA_BASE: 0x3B4 */
}else {
*cp = was; // 还原原来的值
addr_6845 = CGA_BASE; /* CGA_BASE: 0x3D4 */
}
/* Extract cursor location */
outb(addr_6845, 14); // 写控制寄存器,0x0E:获得cursor location high,其值在下一个寄存器
pos = inb(addr_6845 + 1) << 8;
outb(addr_6845, 15); // 写控制寄存器,0x0F:获得cursor location low,其值在下一个寄存器
pos |= inb(addr_6845 + 1);
crt_buf = (uint16_t*) cp; //临时变量赋值给全局变量
crt_pos = pos; //保存当前光标位置
}
阅读(1711) | 评论(0) | 转发(0) |