[comp.os.msdos.programmer] Turbo C

dennett@usage.csd.unsw.oz.au (Dennett Jaques) (08/04/90)

G'day there,

I am having a small problem with some functions in Turbo C 2.01 relating
to 'gets' and 'scanf' when in graphics mode.

The program runs fine on EGA VGA displays but the same code when run on
Hercules equipped machines causes small lines of scattered pixels to be
displayed across the top half of the screen at the point where 'scanf' or
'gets' are called. Additional pixels appear as keyboard input is processed 
by these functions. No characters are echoed to the screen at this time
although they should be, EGA and VGA OK here.

On the other hand if I program using 'getch' in place of the above - this
works for all types of graphics cards.
But this method is too sloppy.

The above code first uses 'InitGraph' to determin display hardware.

Anybody have any thoughts?


  
  Cheers.

  Dennett Jaques.

             _________________________________________________________________
            
   ,-_|\     Network Analyst             E-mail: dennett@usage.csd.unsw.edu.au
  /     \    The University of N.S.W     Phone:  +61 2 697-2324
  \_,-._* <- Sydney, AUSTRALIA           FAX:    +61 2 662-8665
       v     _________________________________________________________________

                         When I want my employers opinion,
                               I'll give it to them.

stever@Octopus.COM (Steve Resnick ) (08/05/90)

In article <789@usage.csd.unsw.oz.au> dennett@usage.csd.unsw.oz.au (Dennett Jaques) writes:
>
>G'day there,
>
G'day !

>I am having a small problem with some functions in Turbo C 2.01 relating
>to 'gets' and 'scanf' when in graphics mode.
>
>The program runs fine on EGA VGA displays but the same code when run on
>Hercules equipped machines causes small lines of scattered pixels to be
>displayed across the top half of the screen at the point where 'scanf' or
>'gets' are called. Additional pixels appear as keyboard input is processed 
>by these functions. No characters are echoed to the screen at this time
>although they should be, EGA and VGA OK here.
>
>On the other hand if I program using 'getch' in place of the above - this
>works for all types of graphics cards.
>But this method is too sloppy.
>
>The above code first uses 'InitGraph' to determin display hardware.
>
>Anybody have any thoughts?
>
>
Time for some good news and some bad news....The good news:
DOS uses the BIOS for video output when not redirected. When you call gets, or
scanf (or anything else that reads stdin and echoes to the console the BIOS 
is called upon to draw your characters. If the EGA/VGA is in graphics mode, 
the characters are still drawn nicely (but more slowly) on the screen and all is
well. 
The bad news: The BIOS video services still think the herc is in mode 7 - MDA
text mode when you are in a hercules graphics mode. This is why you get extra
pixels and no text. To read a string from the console in a herc graphics mode
I believe you will have to code this yourselfand it may mean using a BGI font
rather than the PC's normal font. If this is a workable solution, I have a 
routine I could mail you (it is at work, and I am at home or I would post it
here) which reads characters from the console, takes care of editing, etc
and deals with "cursor" movement (there is normally no cursor in graphics mode).

If this is something that is workable for you let me know and I will e-mail you
the source for this routine (gcgets) it's only about 15 lines of code. If
anyone else is interested, let me know, and I will post it here as well.. :)

Hope this helps.....
Steve



-- 
----------------------------------------------------------------------------
steve.resnick@f105.n143.z1@FIDONET.ORG #include<std_disclaimer.h>
Flames, grammar errors, spelling errrors >/dev/nul
----------------------------------------------------------------------------

gordon@osiris.cso.uiuc.edu (John Gordon) (08/06/90)

	Have you linked in all of the appropriate *.BGI files?  Specifically
the hercules BGI file?


---
John Gordon
Internet: gordon@osiris.cso.uiuc.edu        #include <disclaimer.h>
          gordon@cerl.cecer.army.mil       #include <clever_saying.h>
GEnie:    j.gordon14                  

it1@ra.MsState.Edu (Tim Tsai) (02/06/91)

  Is Turbo C++ (more accurately, the Turbo C compiler included with
Turbo C++) handling varargs differently than the previous versions??
I'm trying to compile a program that looks something like this:

common.h:
#ifdef PROTO
#define ARGS (a) a
#else
#define ARGS (a) ()
#endif

program.c: (PROTO defined)
#include "common.h"

void error ARGS ( (int kind, ...) );

void error (kind, format)
int kind;
char *format;
{
  code that uses stdarg here.
}

  When I try to compile program.c using tcc, it chokes at the line:

    int kind;

  with the error "redeclaration of error at line ##".  Any ideas?

  PS:  No, I don't have a manual.  We have a site license, and the only
time I use it is to compile programs other people wrote.

  PSS: The program supposedly compiles on previous versions of Turbo C.

  Thanks very much in advance..

-- 
  Now I lay me down to rest, a pile of books upon my chest.
  If I should die before I wake, that's one less test I'll have to take.