972
edits
[unchecked revision] | [unchecked revision] |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
|||
(10 intermediate revisions by 5 users not shown) | |||
Line 19:
For instance, using <tt>0x00</tt> as attribute byte means black-on-black (you'll see nothing). <tt>0x07</tt> is lightgrey-on-black (DOS default), <tt>0x1F</tt> is white-on-blue (Win9x's blue-screen-of-death), <tt>0x2a</tt> is for green-monochrome nostalgics.
For colour video cards, you have 32 KB of text video memory to use. Since 80x25 mode does not use all 32 KB (80 x 25 x 2
When you print to any other page than 0, it will ''not'' appear on screen until that page is ''enabled'' or ''copied'' into the page 0 memory space.
====Color Table====
{| {{wikitable}}
|-
! Color number
! Color name
! RGB value
! Hex value
|-
| 0
| Black
| 0 0 0
| 00 00 00
|-
| 1
| Blue
| 0 0 170
| 00 00 AA
|-
| 2
| Green
| 0 170 0
| 00 AA 00
|-
| 3
| Cyan
| 0 170 170
| 00 AA AA
|-
| 4
| Red
| 170 0 0
| AA 00 00
|-
| 5
| Purple
| 170 0 170
| AA 00 AA
|-
| 6
| Brown
| 170 85 0
| AA 55 00
|-
| 7
| Gray
| 170 170 170
| AA AA AA
|-
| 8
| Dark Gray
| 85 85 85
| 55 55 55
|-
| 9
| Light Blue
| 85 85 255
| 55 55 FF
|-
| 10
| Light Green
| 85 255 85
| 55 FF 55
|-
| 11
| Light Cyan
| 85 255 255
| 55 FF FF
|-
| 12
| Light Red
| 255 85 85
| FF 55 55
|-
| 13
| Light Purple
| 255 85 255
| FF 55 FF
|-
| 14
| Yellow
| 255 255 85
| FF FF 55
|-
| 15
| White
| 255 255 255
| FF FF FF
|-
|}
==Printing Strings==
Line 27 ⟶ 118:
If you have a pointer to video memory and want to write a string, here is how you might do it;
<
// note this example will always write to the top
// line of the screen
Line 39 ⟶ 130:
}
}
</syntaxhighlight>
This simply cycles through each character in the string, and copies it to the appropriate place in video memory.
Line 45 ⟶ 136:
For a more advanced print function, you need to store variables for x and y, as the display controller will not print a newline. This involves a switch statement or similar construct.
You also have to test for x>80 or y>25 and in the case of x>80 setting x to 0 and incrementing y, or in the case of y>25 scrolling.
==Printing Integers==
Line 97 ⟶ 154:
Here is an example implementation of the itoa() function (which is not standard, but provided by many libraries):
<
char * itoa( int value, char * str, int base )
{
Line 135 ⟶ 192:
return rc;
}
</syntaxhighlight>
[http://www.strudel.org.uk/itoa/ And here is a shorter one]
Line 142 ⟶ 199:
=== Nothing is Displayed ===
Keep in mind that this way of writing to video memory will
([[GRUB]] does this setup for you.)
Line 172 ⟶ 229:
==See Also==
*[[Printing to the screen without a db]]
[[Category:Tutorials]]
[[Category:Video]]
[[Category:Text UI]]
|