www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/30/14:24:51

From: Elliott Oti <e DOT oti AT stud DOT warande DOT ruu DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: direct access of text screen for mode 0x03
Date: Sun, 29 Dec 1996 23:49:44 -0800
Organization: Academic Computer Centre Utrecht, (ACCU)
Lines: 42
Message-ID: <32C77418.66F8@stud.warande.ruu.nl>
References: <32C0B210 DOT 1BC6 AT zip DOT com DOT au>
NNTP-Posting-Host: warande1078.warande.ruu.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Dean wrote:
> 
> Can I directly access the screen in mode 0x03 (normal text mode) so that
> I can write charicters directly to the screen, and if so (or if not for
> that matter...) ho do I change the default background/foreground colours
> so that I can have different colours all over the place:)
> 
> Also, if I can't acces the screen directly (though I can't really see
> any reason why not) can I still put stuff on the screen without printf
> or whatever?
> 
> Any help would really be appreciated...

Text screen memory begins at 0xb8000 on VGA's under DJGPP.
In contrast to mode 13h, it consists of short ints instead of chars.
The lower byte is the ASCII code of the character, the higher byte is the 
attribute.

In the attribute byte, the lowest 4 bits determine the foreground colour,
giving 16 wonderful colours to choose from.
The highest 4 bits determine the background colour. If the last bit is set,
the character blinks (as the cursor does). Under ANSI.SYS setting the last
bit produces an inverse (reverse foreground/background) instead of blinking. 

You access text screen memory either conventionally, using dosmemput() or
by using far pointers (farspokew()), just as you would any in other mode.

You can also use near pointers: #include <sys/nearptr.h>
turn protection off with __djgpp_nearptr_disable() 
and use  short *TextVid = (short *)(0xb8000 + __djgpp_conventional_base)
as you would a pointer in real mode.

Finally, although coding routines in text mode yourself is neither difficult,
nor particularly time-consuming, <conio.h> contains several routines which
can make your life easier: ScreenPutChar(), clrscr(),etc, and do not require
fiddling around with pointers. They will be somewhat slower than direct screen
writes, but the difference is undetectable unless you're writing a real-time
textmode plasma or something ;-)
Do info libc functional conio  to get an overview of available functions.


Elliott

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019