[alt.msdos.programmer] Quick Screen Access in C

chrisb@escargot.UUCP (Chris Bradley) (01/02/90)

Greetings all,

I have a need to do quick access to the video screen (instead of loading 
ANSI.SYS and using printf(''); commands for video cursor control.) I know that
QUICK Basic will absolutely scream with print's. Is there anything equivalent
in C? By the way, I'm using MSC 5.1.

-->Chris

hollen@eta.megatek.uucp (Dion Hollenbeck) (01/02/90)

From article <3659@escargot.UUCP>, by chrisb@escargot.UUCP (Chris Bradley):
> Greetings all,
> 
> I have a need to do quick access to the video screen (instead of loading 
> ANSI.SYS and using printf(''); commands for video cursor control.)
> 

If all you want is quick cursor control, why not use "int86" or "int86x"
(check the manual for which one is appropriate) to invoke the BIOS
INT 10H for video control.  One of the functions will set the cursor
position for you with very little overhead.  It is also portable to
any decent clone.  Even if the video is real strange, the BIOS 
interface will generally be compatible.

	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

        uunet!megatek!hollen       or  hollen@megatek.uucp

kaleb@mars.jpl.nasa.gov (Kaleb Keithley) (01/03/90)

In article <3659@escargot.UUCP> chrisb@escargot.UUCP (Chris Bradley) writes:
>Greetings all,
>
>I have a need to do quick access to the video screen (instead of loading 
>ANSI.SYS and using printf(''); commands for video cursor control.) I know that
>QUICK Basic will absolutely scream with print's. Is there anything equivalent
>in C? By the way, I'm using MSC 5.1.
>
>-->Chris

Well, it's definitely not portable, but it's faster than anything else around,
and you can test for hardware in order to make it more portable, but this is
what I did for some dedicated software...

struct char_attr {
        char     ch;
        unsigned char attr;
};

struct Screen {
        struct char_attr screen[25][80];
};

main()

{

        int loop;
        struct Screen far *screen = 0xB8000000;

        for (loop = 0; loop < 25; loop++)
                screen->screen[loop][loop].ch = 'A';

}

This code is not intended to be the finest example of coding around, but if it
gives you any ideas...

Note: b8000000 is the address for all color monitors, in text mode, I believe
in either 25, 43, and 50 row mode.  for Herc mono, use 0xB0000000.

Have fun...



Chewey, get us outta here!
                 
kaleb@mars.jpl.nasa.gov             (818)354-8771
Kaleb Keithley

sitze@nmsu.edu (Richard Sitze) (01/06/90)

(I killed post-news just as I started to post, so I'm retrying this,
sorry if you read this twice).

In the overview section of the Library Reference manual (a handy
section to have!), on page 65:

Console and Port I/O

I'm sure these routines use the BIOS calls to talk to the port.
If you want anything faster, use the pointers mentioned by someone
else... But if you have an older CGA (or other type of display) then
watch out for a flakey screen with direct access to the memory.

Also, poking to memory won't move the cursor...

		<ras>

CMH117@PSUVM.BITNET (Charles Hannum) (01/07/90)

... or you can get a copy of a high performance windowing system, like C-Scape
(commercial) or the C Window BOSS (shareware), or one of many, many others.  I
will be distributing my own (portable!) windowing system some time this summer.
Anyway, look around.  Some of these are mighty fine packages, with advanced
input functions, complete windowing functions, "smart" line drawing functions,
and many other nice features.  Some, like CXL, even have extended and expanded
memory, and mouse functions.

Anyway, there's a lot of software out there that will do what you want.  Just
look around.