[an error occurred while processing this directive]
Next:Graphics and Windows,
Q: I try to access the video memory at
0xa0000, but my
program crashes with SIGSEGV....
Q: How can I access the text-mode video memory of my VGA?
A: Absolute addresses of memory-mapped devices are mapped
differently under DJGPP than what you might be used to under other DOS
development environments. That's because DJGPP is a protected-mode
environment, in which you can't just poke any address: that's what
protected mode is all about! To access such absolute addresses, use the
so-called "farptr" functions like
_farpokew; they are described in the C Library reference.
See more details on using "farptr" functions to access absolute addresses in low memory, below.
For text-mode screen updates, you can use the
ScreenUpdateLine library functions to quickly update the screen
from a buffer prepared in memory.
_farpeekX/_farpokeX paradigm to access memory isn't
much slower than direct access (they compile into 2 machine instructions
when optimizations are enabled). But if you need even faster access
(and don't want to write it in assembly), see using the "nearptr" access facilities, as
Some examples of how to access video memory from DJGPP programs are available in Brennan Underwood's tutorial.