Page 1 of 1

Background Colours

Posted: Fri Sep 12, 2008 9:08 pm
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.

Re: Background Colours

Posted: Fri Sep 12, 2008 9:35 pm
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).

Re: Background Colours

Posted: Sun Sep 14, 2008 8:30 pm
by PatrickV
Thanks for that JackScott