首页 > 解决方案 > 改变显示颜色的属性字节

问题描述

我正在尝试更改属性字节以允许白色文本和蓝色背景,我目前在黑色上有 0x07 浅灰色。我可以得到蓝色背景,但不能得到白色文本。我试过 1x15 1x15f 都不管用。任何反馈或链接资源将不胜感激。

void kmain(void)
{
    const char *str = "my first kernel";
    char *vidptr = (char*)0xb8000;  //video mem begins here.
    unsigned int i = 0;
        unsigned int j = 0;

/* this loops clears the screen
* there are 25 lines each of 80 columns; each element takes 2 bytes */
    while(j < 80 * 25 * 2) {
    /* blank character */
        vidptr[j] = ' ';
    /* attribute-byte - light grey on black screen */
        vidptr[j+1] = 0x07;         
        j = j + 2;
    }

标签: c

解决方案


推荐阅读