From: "Ben Peddell" Newsgroups: comp.os.msdos.djgpp References: <10780N882 AT web2news DOT com> Subject: Re: VGA DAC programming Lines: 100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Mon, 13 Jan 2003 14:15:20 +1000 NNTP-Posting-Host: 144.134.90.244 X-Trace: newsfeeds.bigpond.com 1042445150 144.134.90.244 (Mon, 13 Jan 2003 19:05:50 EST) NNTP-Posting-Date: Mon, 13 Jan 2003 19:05:50 EST Organization: Telstra BigPond Internet Services (http://www.bigpond.com) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Check the values of the ATC Palette values. Believe it or not, all VGA modes, except 8-bit or higher, use *both* the ATC Palette and the RAMDAC Palette. The reason that it works under BASIC is that BASIC sets all of the ATC palette values to their indexes. However, INT 0x10 does not do so. If you don't believe me, try the following BASIC code: SCREEN 12 FOR N=0 TO 15 LINE (N*20,0)-STEP(19,100),N,BF NEXT SLEEP FOR N=0 TO 15 X = INP(&H3DA) OUT &H3C0, N OUT &H3C0, RND * 64 NEXT X = INP(&H3DA) OUT &H3C0, &H20 X = INP(&H3C0) X = INP(&H3DA) SLEEP END This should first produce the expected colour bars, then after pressing a key, change the colours to random ones. Try the following code: { char n, x; for (n=0; n<16; n++){ x = inportb (0x3DA); outportb (0x3C0,n); outportb (0x3C0,n); } outportb (0x3C0, 0x20); x = inportb (0x3C0); x = inportb (0x3DA); } Hope this helps. Joel_S wrote in message news:10780N882 AT web2news DOT com... > I just ran into a problem that I've never had before trying to alter the > palettes in screen mode 0x12. I can do this just fine using a VBDOS > compiler (QuickBasic compatible) but using DJGPP, or even the real mode > Turbo C++ 3.0 not all of the colors from 0 to 8 can be changed, and none > of the colors from 9 to 15 can be changed at all. > Here's a simple program that's supposed to > 1) Switch to VGA mode 0x12 > 2) Change the color 12 to puple. > 3) Draw a line using the color 12. > It doesn't work. Here it is... > #include > main() > { > // Switch to screen 12h > unsigned int X; > __dpmi_regs r; > r.x.ax = 0x12; > __dpmi_int(0x10, &r); > /*******************/ > // Set the color 12 to bright purple > outportb(968, 12); > outportb(969, 63); > outportb(969, 0); > outportb(969, 63); > /*******************/ > // Plot a line across half the screen > for(X = 0; X < 320; X++) { > r.h.ah = 0x0C; > r.h.al = 12; > r.h.bh = 0; > r.x.cx = X; > r.x.dx = 240; > __dpmi_int(0x10, &r); > } > /******************/ > // Wait for a key press > r.x.ax = 0; > __dpmi_int(0x16, &r); > /******************/ > // Return to text mode > r.x.ax = 3; > __dpmi_int(0x10, &r); > /********************/ > // Exit this program. > return 0; > } > Any help is appreciated, thanks. > -- > Posted via http://web2news.com the faster web2news on the web