Printing To Screen: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
(Added color table)
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(2 intermediate revisions by 2 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, 4000= 4,000 bytes per screen), you have 8 display pages to use.
 
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.
Line 113:
|-
|}
 
 
 
==Printing Strings==
Line 120 ⟶ 118:
If you have a pointer to video memory and want to write a string, here is how you might do it;
 
<sourcesyntaxhighlight lang="c">
// note this example will always write to the top
// line of the screen
Line 132 ⟶ 130:
}
}
</syntaxhighlight>
</source>
 
This simply cycles through each character in the string, and copies it to the appropriate place in video memory.
Line 156 ⟶ 154:
Here is an example implementation of the itoa() function (which is not standard, but provided by many libraries):
 
<sourcesyntaxhighlight lang="c">
char * itoa( int value, char * str, int base )
{
Line 194 ⟶ 192:
return rc;
}
</syntaxhighlight>
</source>
[http://www.strudel.org.uk/itoa/ And here is a shorter one]