Xref: utzoo comp.graphics:9824 comp.sys.ibm.pc:43954 Path: utzoo!attcan!uunet!dino!ux1.cso.uiuc.edu!brutus.cs.uiuc.edu!psuvax1!psuvm!iap From: IAP@psuvm.psu.edu (Kirk Hanawalt) Newsgroups: comp.graphics,comp.sys.ibm.pc Subject: VGA - direct memory access question Message-ID: <90039.091705IAP@PSUVM.BITNET> Date: 8 Feb 90 14:17:05 GMT Organization: Penn State University Lines: 44 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. Using the TurboC getpixel function, the 640x480 graphics screen can be dumped in about 35 seconds. I would like to access memory directly, and dispense with getpixel() altogether. Unfortunately, I can't figure out how the pixels are mapped in memory. Starting at address A000:0000, each byte in memory seems to indicate the on/off state of 8 pixels on the screen. For example, the statement: *((unsigned char far *) 0xa0000000L) = 0x80; turns the first pixel in the first row of the graphics screen on. I can use this method to get monochrome graphics. Obviously, 16 color graphics requires 4 bits to specify pixel color. The problem is this: when using this method to read pixels from the screen, I only get the odd color pixels (for the default EGA/VGA palette 1=blue, 3=cyan,...,15=white). The even color pixels do not have a bit set. 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 */ This method dumps the screen to the LaserJet in about 15 seconds, so I would like to use it. However, getting only half of the displayed colors printed is a drawback :-). My question is this: where in the heck are the pixel values stored in memory for the VGA adapter in 640x480 16 color mode? Every book I've seen covers only monochrome graphics and uses the method above to write/read pixels. ------- Kirk Hanawalt | | Chem. Eng. Dept. | BITNET: IAP @ PSUVM | Penn. St. Univ. | OTHER: ...!psuvax1!iap@psuvm.bitnet |