Background Colours

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Background Colours

Post by PatrickV »

Does anyone know how to make a blank screen with a colour of their choice . By default is black. I don't want them to have a prompt code to enter a value or command. I jut want it as part of a program background. I am using nasm to create my os.
User avatar
JackScott
Member
Member
Posts: 1036
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Background Colours

Post by JackScott »

Relevant Wiki page: http://wiki.osdev.org/Text_UI

Basically, the VGA text area at 0xB8000 can be thought of as an array of 16-bit words. Each word has two parts: the ASCII character in the lower byte, and the colour attribute in the upper byte. To prepare a blank screen in the colour of your choice, prepare a word with ASCII character 0x20 (space) in the lower byte, your colour choice in the upper byte (following this guide), and memcpy() that word 80x25 times over the screen area. Done. Then when you write an actual character to the screen, you just have to remember to use the same colour attribute byte (or alternatively, only change the character byte).
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: Background Colours

Post by PatrickV »

Thanks for that JackScott
Post Reply