Path: | icdoc!tsun4.doc.ic.ac.uk!zmact61 |
From: | zmact61@tsun4.doc.ic.ac.uk.doc.ic.ac.uk (D Spinellis) |
Newsgroups: | comp.graphics,comp.sys.ibm.pc |
Subject: | Re: VGA - direct memory access question |
Summary: | You need to specify which memory map to access |
Keywords: | VGA memory planes |
Message-ID: | <1575@gould.doc.ic.ac.uk> |
Date: | 9 Feb 90 12:03:57 GMT |
References: | <90039.091705IAP@PSUVM.BITNET> |
Sender: | news@doc.ic.ac.uk |
Reply-To: | dds@cc.ic.ac.uk (Diomidis Spinellis) |
Organization: | Imperial College Department of Computing |
Lines: | 49 |
Content-Length: | 2220 |
In article <90039.091705IAP@PSUVM.BITNET> IAP@psuvm.psu.edu (Kirk Hanawalt) writes:
>
> I'm trying to write a program (TurboC 2.0, IBM PS/2 Model 50
>with VGA adapter, HP LaserJet II) to dump a bitmap image of the
>high resolution VGA screen to a LaserJet printer.
[...]
>Unfortunately, I can't figure out how the pixels are mapped in
>memory.
[...]
The EGA and VGA cards have all the color planes mapped into the same
memory address. You specify from which color plane you want to read
or write by outputing appropriate values to the various card controller
registers. Different read and write modes give you the ability to access
the planes together; naturally with some restrictions. For example you can
write a color value to a specified pixel, or you can set all color planes
to the same value. The Technical Reference Manual for the PS/2 systems
covers these things.
> The problem is this: when using this method to read pixels
>from the screen, I only get the odd color pixels
>The following pseudo-code
>works only for odd colors, the even colors aren't printed.
>
> ptr=(unsigned char huge *) 0xa0000000L;
> for (j=0; j<=MaxY; j++)
> for (i=0; i < (MaxX+1)/8; i++)
> Send_To_Printer(*ptr++); /* send byte = 8 pixels */
>
[...]
You need to modify your code to access the four color planes. Register 4
in address 0x3cf can be set to specify which plane you want to read. You
must set the index register in address 0x3ce to 4 to point to the correct
register. The following code should work:
outp(0x3c4, 4); /* Set index register */
ptr=(unsigned char huge *) 0xa0000000L;
for (j=0; j<=MaxY; j++)
for (i=0; i < (MaxX+1)/8; i++, ptr++)
for (k = 0; k < 4; k++) {
outp(0x3cf, k); /* Specify color plane */
Send_To_Printer(*ptr, k); /* send byte = 8 pixels */
}
Diomidis
--
Diomidis Spinellis Internet: dds@cc.ic.ac.uk
Department of Computing BITNET: dds@cc.ic.ac.uk
Imperial College UUCP: ...!cernvax!cc.imperial.ac.uk!dds
London SW7 2BZ JANET: dds@uk.ac.ic.cc
Newsgroup comp.graphics contents
Newsgroup list
Diomidis Spinellis home page
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.