mgreen@cs.toronto.edu (Marc Green) (08/23/90)
I have a crash project to write a graphics program in Turbo C on a 286 with a VGA card. I have already done much C graphics programming on other hardware, but am mystified by the complexities of VGA cards. I am hoping to get some answers to specific questions. (The project simply involves drawing geometric shapes of different color and doing animation.) 1) How do you set colors lookups? (All those different registers are crazy! Who designed this thing anyway?!) 2) How do you plot on different pages and do page flipping. 3) Is there some way to catch the video sync pulse (for page flipping)? Is there someway to send out a signal from the sync pulse? 4) Is there some PD software to make life easier. Marc Green
joe@proto.COM (Joe Huffman) (08/24/90)
In article <90Aug23.104901edt.9569@neat.cs.toronto.edu>, mgreen@cs.toronto.edu (Marc Green) writes: > > I have a crash project to write a graphics program in Turbo C on a 286 > with a VGA card. I have already done much C graphics programming on > other hardware, but am mystified by the complexities of VGA cards. I It took me several weeks of staring at the IBM EGA technical reference manual and poking around with a debugger, crashing the system, etc to figure out the EGA card. The VGA is built upon this slime pit of an excuse for a graphics adapter. I wrote the graphics library that is sold with the Zortech C/C++ compiler. We call it FG for 'Flash Graphics'. Why not use an existing graphics library? Turbo C has one. Other vendors support Turbo C also if you are stuck with the Borland product as your compiler :-). If you are insistent on doing it yourself get "Programmer's Guide To PC & PS/2 Video Systems" by Richard Wilton, Microsoft Press, ISBN 1-55615-103-9. Also recommended are some of the clone vendors technical reference manuals. Headland Technology (Video Seven) sells one for their 1024i board that is excellent and only costs $10.00 (or at least it did a few months ago). Their phone number is 800-248-1850 (outside CA) or 800-553-1850 (inside CA). Have your charge card ready. Also, it is a job for assembly language not C. It can be done in C but it is much easier doing it in assembly. At least the low level stuff, that actually 'talks' to the board. > 1) How do you set colors lookups? (All those different registers are > crazy! Who designed this thing anyway?!) Use the BIOS functions (AX = 1010h, BX = color number, CH = green, CL = Blue, DH = Red, then do int 10h) or with FG call fg_setpalette(). RGB values are 6 bits maximum. The designers of the VGA had to add another level of indirection into the palette to get a total palette of 2^18 and still be sort of compatible with the EGA. It took me a couple days to get this figured out. None of the references really had any examples and just did these nearly useless descriptions of the hardware that were incredably complex (and I have a MSEE) and the code for the EGA didn't work with the VGA unless it was emulating an EGA mode. The trick is that you getting the 'color number' to work right. Do a int 10h with AX = 1002h with ES:DX pointing to a 17 byte table that is 0 -> 15 in order followed by a 0. This is done once after the graphics mode has been entered. Then the color number is just a number between 0 and 15 (inclusive) instead of some strange non- sequence that varies from 0 to 37h (or something like that). Then when you write a pixel out with a color number of (say) 6 the RGB value you set up with the first BIOS call I described for BX == 6 will be the color of the pixel on the screen. > 2) How do you plot on different pages and do page flipping. Not all modes have multiple pages. Of the VGA specific modes only mode 0x13 (320 x 200 x 256 colors) has more than one page (it has 4). Set AH = 05h, AL = page number, then do int 10h to flip pages. I haven't implemented this function for mode 0x13 so I'm not sure how to write to the other pages. If you buy the Zortech Compiler and need the multiple pages for mode 0x13, let me know and I can probably get it to you in a week or so. > 3) Is there some way to catch the video sync pulse (for page > flipping)? Is there someway to send out a signal from the sync pulse? Yes. Get the references. I think all BIOS's do that for you. What type of signal? Clicking the speaker? Yes. > 4) Is there some PD software to make life easier. There's too much frustation, sweat, and tears invested to let FG out for free. I invested my time, a small amount of advice is free, if you want MY software you can buy it. Source code will be available soon if that makes any difference to anyone... again for a price. You qualify for an educational discount on the compiler so you could switch to Zortech for about $75.00 and I would be able to help make life a bit easier for you... -- joe@proto.com uunet!proto!joe FAX: 208-263-8772
joe@proto.COM (Joe Huffman) (08/25/90)
In article <1402@proto.COM>, joe@proto.COM (Joe Huffman) writes: > Not all modes have multiple pages. Of the VGA specific modes only mode 0x13 > (320 x 200 x 256 colors) has more than one page (it has 4). The VEGA VGA technical reference manual has an error on page 2-12. It says that mode 0x13 has 4 pages. This is not true. It only has one. I am sorry I didn't check further when made my earlier statement. I also said that I would modify FG to support the additional pages if someone requested it. I obviously cannot do that... -- joe@proto.com uunet!proto!joe FAX: 208-263-8772