Background Colours
Background Colours
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.
- JackScott
- 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
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).
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).
Re: Background Colours
Thanks for that JackScott