0

I want to do 1024*768 programming in Turbo C++ I am using Turbo C 3.0 where i am using the old VGA method to invoke graphics initgraph( &GraphDriver, &GraphMode, "..\\bgi" );

I want a library which can easily handle the SVGA mode and true colors.

genpfault
  • 51,148
  • 11
  • 85
  • 139
rehmankhan
  • 41
  • 6
  • 1
    Unfortunately asking for a library recommendation is explicitly against the rules of the site; otherwise this is a good question, since it's esoteric knowledge that will be hard to find elsewhere. – Mark Ransom Mar 02 '17 at 17:08
  • That's probably not possible with a compiler/graphics library that was created before these technologies were even established. – πάντα ῥεῖ Mar 02 '17 at 17:08
  • http://www.svgalib.org – Mark Setchell Mar 02 '17 at 19:55
  • @Mark Stechell, I think that SVGALIB is Linux only, I do not think that SVGALIB was ported to MSDOS (the question was for TurboC++ / MSDOS). – BrunoLevy Mar 02 '17 at 21:13
  • @BrunoLevy Ah, yes, quite possibly - thank you. Yet, if OP is dead-set on 1990's tech, maybe he is happy to use Linux in a Virtualbox to get to that 90's nirvana :-) – Mark Setchell Mar 02 '17 at 21:23
  • see [vesapag,vesamod](https://stackoverflow.com/a/45780565/2521214) subroutines ant its use. It is in asm but you can use inline assembly `asm { asm code here };` and [Display an array of color in C](https://stackoverflow.com/a/21699076/2521214) you just set the wanted video mode, then set the page you want to work with and then work with memory at `0A000h` segment – Spektre Aug 30 '17 at 07:30

1 Answers1

4

There are several chip manufacturers for SVGA cards, and programming them may require specific code for each of them (unless your graphic board supports VESA, see below). I did that ages ago (in the 90s'), and I used the sources of POVRAY (a raytracer) as a reference.

Fortunately, POVRAY still exists today: http://www.povray.org/

You need to grab here http://www.povray.org/ftp/pub/povray/Old-Versions/ the sources of an old 1990's version that still has the routines for SVGA (the authors probably removed them in the recent versions !). You will find in the sources a bunch of inline assembly functions to initialize graphic mode and set a pixel for various graphic boards/manufacturers (S3, ET4000, ...). First unzip POVSRC.ZIP, then MACHINE.ZIP, then IBMPC.ZIP (and it is in IBM.C).

The code is a bit esoteric: this is because initially the IBM PC was meant to have no more than 64Kb of video ram (at segment A000:0000). To allow having higher resolution, there is a technique that is called "bank switching", that allows changing a "window" in video RAM that is mapped to A000:0000.

If your SVGA board supports the VESA standard (which is the case for most of them), then things might be easier, there is a standard interrupt for changing the graphic mode and for doing the bank switching (so you probably just need to find in POVRAY the VESA implementation of "set graphic mode" and "set pixel").

Finally, I mention djgpp (g++ port to MSDOS) that has both a 32 bit DOS extender and a graphic library (grx) that uses the virtual memory in a nifty way to simulate a contiguous graphic memory (it creates virtual addresses for the video RAM and uses page faults interrupts to trigger bank switching automatically). I used it to do 3D graphic programming on a 33Mhz 486.

Edit: After digging a bit, I found that the latest version that has the routines is the one here: http://www.povray.org/ftp/pub/povray/Old-Versions/Official-3.1g/MS-Dos/

unzip povmsd_s.zip

The routines are in SOURCE/MSDOS/VESAVBE.{H,C} (usable if your cards supports the VESA norm). Other cards have their routines in SOURCE/MSDOS/MSDOSVID.C

BrunoLevy
  • 2,495
  • 17
  • 30