MikeFoster
March 31, 2001, 05:25 am
When you start learning the C language you start to realize that you have ultimate control over that machine. C doesn't try to isolate you from the hardware - in fact it encourages you to explore the hardware!
One of first things that really blew me away was being able to write directly to the video buffer in RAM. Its really fast! But even tho it doesn't take much C code to do it, there are several important hardware concepts that you'll have to grapple with... before you can run your program without making your PC crash and burn! LOL!
So here you go... Crash that machine and enjoy doing it!
/* Output a string at specified X,Y coordinates.*/
void xyputs(int x, int y, char *str)
{
while(*str) outchar(x++, y, *str++);
}
/* Output a character at specified X,Y coordinates.*/
void outchar(int x, int y, char ch)
{
char far *v = (char far *) MK_FP(0xB800, 0000);
v += (y*160) + x*2; /* compute char loc */
*v++ = ch; /* write the character */
*v = 7; /* default attribute */
}
------------------
Try these HelpFromTechs.com Web Development Resources:
Reference Links (http://www.helpfromtechs.com/ubb/Forum8/HTML/000054.html)*|*User Authentication (http://www.helpfromtechs.com/ubb/Forum8/HTML/000071.html)*|*HTML Editors (http://www.helpfromtechs.com/ubb/Forum8/HTML/000030.html)*|*Perl/CGI (http://www.helpfromtechs.com/ubb/Forum8/HTML/000016.html)*|*Embedding Music (http://www.helpfromtechs.com/ubb/Forum8/HTML/000067.html)
One of first things that really blew me away was being able to write directly to the video buffer in RAM. Its really fast! But even tho it doesn't take much C code to do it, there are several important hardware concepts that you'll have to grapple with... before you can run your program without making your PC crash and burn! LOL!
So here you go... Crash that machine and enjoy doing it!
/* Output a string at specified X,Y coordinates.*/
void xyputs(int x, int y, char *str)
{
while(*str) outchar(x++, y, *str++);
}
/* Output a character at specified X,Y coordinates.*/
void outchar(int x, int y, char ch)
{
char far *v = (char far *) MK_FP(0xB800, 0000);
v += (y*160) + x*2; /* compute char loc */
*v++ = ch; /* write the character */
*v = 7; /* default attribute */
}
------------------
Try these HelpFromTechs.com Web Development Resources:
Reference Links (http://www.helpfromtechs.com/ubb/Forum8/HTML/000054.html)*|*User Authentication (http://www.helpfromtechs.com/ubb/Forum8/HTML/000071.html)*|*HTML Editors (http://www.helpfromtechs.com/ubb/Forum8/HTML/000030.html)*|*Perl/CGI (http://www.helpfromtechs.com/ubb/Forum8/HTML/000016.html)*|*Embedding Music (http://www.helpfromtechs.com/ubb/Forum8/HTML/000067.html)