Welcome to the Linux Foundation Forum!
Developing kernel: Hex for text color?
macaswell
Posts: 14
I'm developing a kernel, but I want to know the hex values for colors. I don't really know how to phrase this question, so here's the code:
#define WHITE_TXT 0x07 // white on black text
#define GREEN_TXT //what I want to know
#define BLUE_TXT //what I want to know
#define RED_TXT //what I want to know
void k_clear_screen();
unsigned int k_printf(char *message, unsigned int line);
k_main() // like main in a normal C program
{
k_clear_screen();
k_printf("mcKlos 1.0.1 -- Copyright (c) Matthew Caswell, 2010\n", 0);
}
void k_clear_screen() // clear the entire text screen
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
unsigned int k_printf(char *message, unsigned int line) // the message and then the line #
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0)
{
if(*message=='\n') // check for a new line
{
line++;
i=(line*80*2);
*message++;
} else {
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
return(1);
};
#define GREEN_TXT //what I want to know
#define BLUE_TXT //what I want to know
#define RED_TXT //what I want to know
void k_clear_screen();
unsigned int k_printf(char *message, unsigned int line);
k_main() // like main in a normal C program
{
k_clear_screen();
k_printf("mcKlos 1.0.1 -- Copyright (c) Matthew Caswell, 2010\n", 0);
}
void k_clear_screen() // clear the entire text screen
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
unsigned int k_printf(char *message, unsigned int line) // the message and then the line #
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0)
{
if(*message=='\n') // check for a new line
{
line++;
i=(line*80*2);
*message++;
} else {
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
return(1);
};
please give me a list.
0
Comments
-
I found a good example with a list on post 49 of http://www.dreamincode.net/forums/topic/21022-change-font-color-in-c-program/0
-
Yeah, that would be great, and I've used that before, but this is a standalone kernel (from boot). The code in that example is for win32 console programming. This is from boot, with it's own boot loader. So, again, the hex values for primary colors?0
-
Here you go, my friend:
BLACK = 00h
BLUE = 01h
GREEN = 02h
CYAN = 03h
RED = 04h
MAGENTA = 05h
BROWN = 06h
GRAY = 07h
DARK GRAY = 08h
BRIGHT BLUE = 09h
BRIGHT GREEN = 0Ah
BRIGHT CYAN = 0Bh
PINK = 0Ch
BRIGHT MAGENTA = 0Dh
YELLOW = 0Eh
WHITE = 0Fh0 -
Thanks, now to add it and test it.0
-
It worked great! Thanks!0
Categories
- 8.9K All Categories
- 13 LFX Mentorship
- 66 LFX Mentorship: Linux Kernel
- 362 Linux Foundation Boot Camps
- 231 Cloud Engineer Boot Camp
- 69 Advanced Cloud Engineer Boot Camp
- 25 DevOps Engineer Boot Camp
- 4 Cloud Native Developer Boot Camp
- 863 Training Courses
- 15 LFC110 Class Forum
- 16 LFD102 Class Forum
- 102 LFD103 Class Forum
- 3 LFD121 Class Forum
- 55 LFD201 Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- 19 LFD254 Class Forum
- 433 LFD259 Class Forum
- 86 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 16 LFS200 Class Forum
- 695 LFS201 Class Forum
- LFS201-JP クラス フォーラム
- 271 LFS211 Class Forum
- 50 LFS216 Class Forum
- 26 LFS241 Class Forum
- 28 LFS242 Class Forum
- 19 LFS243 Class Forum
- 6 LFS244 Class Forum
- 9 LFS250 Class Forum
- LFS250-JP クラス フォーラム
- 109 LFS253 Class Forum
- 794 LFS258 Class Forum
- 7 LFS258-JP クラス フォーラム
- 51 LFS260 Class Forum
- 79 LFS261 Class Forum
- 14 LFS262 Class Forum
- 76 LFS263 Class Forum
- 14 LFS264 Class Forum
- 10 LFS266 Class Forum
- 8 LFS267 Class Forum
- 9 LFS268 Class Forum
- 6 LFS269 Class Forum
- 181 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- 187 LFW211 Class Forum
- 104 LFW212 Class Forum
- 879 Hardware
- 207 Drivers
- 74 I/O Devices
- 43 Monitors
- 115 Multimedia
- 205 Networking
- 98 Printers & Scanners
- 82 Storage
- 724 Linux Distributions
- 82 Debian
- 64 Fedora
- 12 Linux Mint
- 13 Mageia
- 22 openSUSE
- 126 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 347 Ubuntu
- 448 Linux System Administration
- 33 Cloud Computing
- 64 Command Line/Scripting
- Github systems admin projects
- 89 Linux Security
- 74 Network Management
- 105 System Management
- 45 Web Management
- 50 Mobile Computing
- 18 Android
- 19 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 500 Off Topic
- 120 Introductions
- 193 Small Talk
- 19 Study Material
- 748 Programming and Development
- 240 Kernel Development
- 474 Software Development
- 902 Software
- 247 Applications
- 178 Command Line
- 2 Compiling/Installing
- 72 Games
- 314 Installation
- 20 All In Program
- 20 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)