[comp.os.msdos.programmer] Hercules graphics with Turbo C and Debugger

Jari.Karjala@niksula.hut.fi (05/27/91)

I have a C/ASM program which sets the Hercules graphics card into the
graphics mode, writes a few bytes to screen and then returns to text
mode. 

When I set the graphics mode through BGI's initgraph() function, I can
singlestep through the following code with Turbo Debugger and the
graphics/text screen is flipped correctly. But if I replace the
initgraph() with my own function to set the graphics mode (and don't
link with graphics.lib), TD no longer notices the mode change and
thinks it is still in text mode (and of course the result is not very
usable).

The question is: what does initgraph do to tell TD that now we are
in graphics mode? Or is there some hidden function in the BGI library
which is used by the debugger?

--
/*--- Jari.Karjala@hut.fi -- The World is Just a Huge Fractal ---*/ 
float O,I,o=0.075,h=1.5,T= -2,r,l;main(){int _=0,L=80,s=3200;for(;s
%L|| (h-=o,T= -2),s;(4-(r=O*O)<(l=I*I)|++_==L)&&write(1,(--s%L?_<L?
--_%6:6:7)+"World! \n",1)&&(O=I=l=_=r=0,T+=o/2))O=I*2*O+h,I=l+T-r;}

sorrow@oak.circa.ufl.edu (06/02/91)

In article <JARI.KARJALA.91May27134636@superman.hut.fi>, Jari.Karjala@niksula.hut.fi writes:
|>
|>When I set the graphics mode through BGI's initgraph() function, I can
|>singlestep through the following code with Turbo Debugger and the
|>graphics/text screen is flipped correctly. But if I replace the
|>initgraph() with my own function to set the graphics mode (and don't
|>link with graphics.lib), TD no longer notices the mode change and
|>thinks it is still in text mode (and of course the result is not very
|
|>
|>The question is: what does initgraph do to tell TD that now we are
|>in graphics mode? Or is there some hidden function in the BGI library
|>which is used by the debugger?

As far as I know, most graphics libraries require a call to a function such
as initgraph() or OpenGraphics() or InitGraphics() or something like that since
graphics stuff is dependent on certain global variables.  My guess would be
that the BGI routines have global variables describing the current page,
current mode, type of video adapter, amount of memory, etc. and all of these
are determined via initgraph().  If you want to write your own graphics 
routines I would do it completely, rather than deal with trying to make your
library work with someone elses (conflicts will arise more than likely).

Brian

/*
Brian Hook -- MS-DOS Programmer for Contract
-----------------------------------------------------------------
"I was in the kitchen, Seamus, that's my dog, was outside....and buried
ALIVE....fritter and waste...but this one goes to 11!....anymore of that
plutonium nyborg?....SNOW TIME!....This is home...this is Mean Street..
*/

frank@cavebbs.gen.nz (Frank van der Hulst) (06/02/91)

In article <009497E5.514A35E0@MAPLE.CIRCA.UFL.EDU> sorrow@oak.circa.ufl.edu writes:
>In article <JARI.KARJALA.91May27134636@superman.hut.fi>, Jari.Karjala@niksula.hut.fi writes:
>|>
>|>When I set the graphics mode through BGI's initgraph() function, I can
>|>singlestep through the following code with Turbo Debugger and the
>|>graphics/text screen is flipped correctly. But if I replace the
>|>initgraph() with my own function to set the graphics mode (and don't
>|>link with graphics.lib), TD no longer notices the mode change and
>|>thinks it is still in text mode (and of course the result is not very
>|
>|>
>|>The question is: what does initgraph do to tell TD that now we are
>|>in graphics mode? Or is there some hidden function in the BGI library
>|>which is used by the debugger?

I've got code which switches a VGA into 320*400*256 colour mode. TC's integrated
debugger certainly recognises that it's in graphics mode, although it treats it
as if it was in 320*200 mode. That's not unreasonable, since the way I enter
the graphics mode is to switch to 320*200 via BIOS call, then twiddle some VGA
registers. Sooo... How are you switching to graphics mode? By calling INT 10h, 
or by changing some registers on your Herc card directly?


-- 

Take a walk on the wild side, and I don't mean the Milford Track.
Kayaking: The art of appearing to want to go where your boat is taking you.