From: Jeff Weeks Newsgroups: comp.os.msdos.djgpp Subject: vga 16 colour (4 bit graphics) Date: 30 Apr 1997 02:03:14 GMT Organization: Code X Software Lines: 54 Message-ID: <5k6992$ed1@nr1.toronto.istar.net> NNTP-Posting-Host: ppp14.tellus.execulink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi everybody, I already know a fair bit about graphics programming, but one of the areas I really lack are in 16 colour modes. I've started reading Michael Abrash's book which starts out with 16 colour modes, but I find it difficult to follow some of his examples. I've written a tiny program (excert follows) which will change the BYTES of VGA memory, but I'm interested in how I would go about actually affecting the BITS in those bytes. I'm under the impression that I would just use the bit mask register. But that doesn't seem to work. Here's some code to illustrate what I'm doing: int y, x; int colour; for(y = 0; y < 350; y++) for(x = 0; x < 640; x++) { colour = (int)rand() % 16; //_farpeekb(_dos_ds,0xA000+y*80+(x/4)); // load the latches set_vga_reg(SC_INDEX,MAP_MASK, 0xF); //set_vga_reg(GC_INDEX,GC_BIT_MASK, x % 8); set_vga_reg(GC_INDEX,GC_ENABLE_SET_RESET, 0xF); set_vga_reg(GC_INDEX,GC_SET_RESET,colour); _farpokeb(_dos_ds,0xA0000+y*80+(x/4), 0xff); } The above code changes the bytes fine. I attempted to affect the bits individually by using the GC_BIT_MASK line, but that didn't work. My logic behind it was: - The remainder of the x value divided by 8 (x % 8) should be the bit we're working on right? - Therefore if I set the bit mask to that value I should only affect that bit right? I have a feeling that I have some things TOTALLY WRONG. So I would hope you guys would put me in my place :) I appreciate any help on this topic. I know 256 colour+ modes, but they're relatively easy compared to this stuff. 16 colour modes present more of a challenge so I'd like to say I can do them! :) Thanks a lot, Jeff -------------------------------------------- - Code X Software - Programming to a Higher Power email: mailto:pweeks AT execulink DOT com web: http://www.execulink.com/~pweeks/ --------------------------------------------