[comp.sys.ibm.pc] Fix for TURBO-C 2.0 Text I/O

mlord@bnr-rsc.UUCP (Mark Lord) (02/08/90)

Hi.  While converting my copy of STEVIE ("vi" knockoff) to use the
built-in Turbo-C text routines (conio.h), I discovered that the library
routines are hardcoded for exactly 25 rows of text.  The number of columns
seems to be correctly obtained from the bios, but the number of rows is
fixed at 25 in the video initialization.

Since I often edit with 30, 40, 50 or 60 lines of text, this was not cool.

I used TLIB and READOBJ together to get a segment listing of the video
initialization module from the libraries, and found an undocumented data
segment called _video .  

Some further probing with TD revealed that this segment holds the internal
copy of the screen/window sizes, as normally queried using getttextinfo().
This makes it trivial to correct this deficiency after startup in any program.

Here is what to do, if YOU want Turbo-C routines to work correctly,
regardless of the number of lines/columns in text mode (mode 3):

	extern struct text_info _video;
	_video.winbottom    = *(char far *) MK_FP(0x40,0x84);
	_video.screenheight = _video.winbottom + 1;

The first line gives you access to the hidden "_video" structure,
the second line reads the actual bottom text row number from the bios
data area, and the third line completes the fixup.

After doing this (like really early in the code eh?), the standard library
gotoxy/insline/deline... routines will then work correctly for screen sizes
other than just the 25-line modes.

That oughta hold us over until May/90..
-- 
 ______Mark S. Lord______________________ ______________________________
|    ..uunet!bnrgate!carrsc!mlord        | These are only MY opinions.  |
| or:  bnr-rsc!mlord@bnrgate             | I charge for official views. |
|________________________________________|______________________________|

CMH117@psuvm.psu.edu (Charles Hannum) (02/10/90)

The Turbo C video functions will recognize screens larger than 25 rows with an
extended BIOS.  With an old BIOS, it assumes 25 rows.

Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117@psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h@psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."

mlord@bnr-rsc.UUCP (Mark Lord) (02/12/90)

In article <90040.114944CMH117@PSUVM.BITNET> CMH117@psuvm.psu.edu (Charles Hannum) writes:
>
>The Turbo C video functions will recognize screens larger than 25 rows with an
>extended BIOS.  With an old BIOS, it assumes 25 rows.

My disassembly of the code indicates otherwise.
Perhaps you have a newer version of "2.0" than I.

I heard from someone else that they had a fix for it.
-- 
 ______Mark S. Lord______________________ ______________________________
|    ..uunet!bnrgate!carrsc!mlord        | These are only MY opinions.  |
| or:  bnr-rsc!mlord@bnrgate             | I charge for official views. |
|________________________________________|______________________________|

CMH117@psuvm.psu.edu (Charles Hannum) (02/12/90)

Sorry.  If you look, there is a call to Int 10h, AL=1130h.  Among other things,
this returns the maximum row number of the current video mode (# rows - 1).
This works only on an extended BIOS, though.  If you have an old BIOS, the
initialization routine senses this and assumes 25 lines.

This is a fact.  Please don't argue.


Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117@psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h@psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."

mlord@bnr-rsc.UUCP (Mark Lord) (02/16/90)

In article <90043.094236CMH117@PSUVM.BITNET> CMH117@psuvm.psu.edu (Charles Hannum) writes:
>
>Sorry.  If you look, there is a call to Int 10h, AL=1130h.  Among other things,
>this returns the maximum row number of the current video mode (# rows - 1).
>This works only on an extended BIOS, though.  If you have an old BIOS, the
>initialization routine senses this and assumes 25 lines.

Yes, I am well aware that the library function does indeed invoke this
extended (EGA/VGA) bios call.  In fact, it even returns the correct number
of rows on the screen!

BUT.. in the library routines that I have (TC 2.00), the initialization 
routine then promptly discards this value without ever making use of it.
This results in the default of 19h being used instead.
>
>This is a fact.  Please don't argue.

These are also facts.  Who's arguing, anyway?

As my original query stated, perhaps YOU have a newer version of the library
in which this bug has already been fixed.  What version of Turbo-C do you have?
Would it be  2.01, perhaps?  Mine is an early copy of 2.00.

Also, the model I'm using for this is the "compact" memory model.
-- 
 ______Mark S. Lord______________________ ______________________________
|    ..uunet!bnrgate!carrsc!mlord        | These are only MY opinions.  |
| or:  bnr-rsc!mlord@bnrgate             | I charge for official views. |
|________________________________________|______________________________|