Mail Archives: djgpp/2000/01/10/10:47:29
On 9 Jan 2000, Martin Str|mberg wrote:
> : How about using _farpokeb, then? It's inline assembly, and doesn't
> : use the stack. You could write the characters with it one by one.
> : Clumsy, but works.
> :
> : Actually, you could even use the assembly instructions from _farpokeb
> : inlined in your code.
>
> The problem I have isn't with the loop or such, but to get something
> out to video memory. I have some kind of basic understanding of
> assembly, but knows very little about PC hardware.
The following snippet puts a red letter 'a' on lightgray background in
the leftmost, topmost corner of the screen (WARNING: UNTESTED CODE!):
_farpokeb (_dos_ds, 0xb8000, 'a');
_farpokeb (_dos_ds, 0xb8001, 0x74);
Each character on the screen takes two bytes in the video memory: the
first holds the character's code, the second its video attribute
byte. The attribute byte (here, 0x74) holds the background color in
its high nibble and the foreground color in its lower nibble. The
color codes begin at 0 and go up in the order the colors are listed in
the "enum COLOR" on conio.h.
To put 'a' in the rightmost lower corner, use 0xb8000 + 160*24 + 158
as the second argument to _farpokeb (assuming 80x25 text screen).
- Raw text -