Screen control functions

O

OziRus

Hi,

This is my first message on this group. I want to ask something about
screen-drawing functions. I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling
with Tc and running in dos might run it? [I didn't try it on linux yet]

Thanks for everything...

#include <stdio.h>
#include <conio.h>

char far *vp=(char far *)0xB0000000;


void _write(int row,int col,int ch)
{
char far *scrp=vp;
scrp+=row*160+col*2;
*scrp=ch;
}

int main()
{
_write(10,10,'t');
_write(10,11,'e');
_write(10,12,'s');
_write(10,13,'t');


return 0;
}
 
J

jacob navia

OziRus said:
Hi,

This is my first message on this group. I want to ask something about
screen-drawing functions. I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling
with Tc and running in dos might run it? [I didn't try it on linux yet]

Thanks for everything...

#include <stdio.h>
#include <conio.h>

char far *vp=(char far *)0xB0000000;


void _write(int row,int col,int ch)
{
char far *scrp=vp;
scrp+=row*160+col*2;
*scrp=ch;
}

int main()
{
_write(10,10,'t');
_write(10,11,'e');
_write(10,12,'s');
_write(10,13,'t');


return 0;
}

You have to run under MSDOS, not windows XP.

Contrary to what *many* people think, MSDOS is dead since more than 10
years, I do not remember exactly when was it, maybe 1995.

Contrary to what many people think, the "DOS WINDOW" is just
an EMULATION of text mode msdos, with the same commands,
etc.

The MSDOS emulation will NOT emulate the writing to screen memory,
as it seems.

Maybe a better idea would be to use the console mode with a 32 bit
compiler, and obtain the same result.

So, you have two solutions:

1) Get a better compiler
2) Get MSDOS and run under msdos by booting from a disquette.
You will get many advantages:
Only 640K of memory. No more problems with that huge amount
of RAM that you do not know what to do about
TC IDE will run better and all dos programs will work.

The choice is yours

jacob
 
O

OziRus

Thanks for your reply;

jacob said:
Get a better compiler

Dev C++ couldn't compile the same code that I used with TC. The errors
were like this;

C:\Tc\BIN\KARAKTER.CPP:4: error: expected init-declarator before '*'
token
C:\Tc\BIN\KARAKTER.CPP:4: error: expected `,' or `;' before '*' token
C:\Tc\BIN\KARAKTER.CPP: In function `void _writec(int, int, int)':
C:\Tc\BIN\KARAKTER.CPP:9: error: expected primary-expression before
"char"
C:\Tc\BIN\KARAKTER.CPP:9: error: expected `;' before "char"

C:\Tc\BIN\KARAKTER.CPP:10: error: `scrp' undeclared (first use this
function)
C:\Tc\BIN\KARAKTER.CPP:10: error: (Each undeclared identifier is
reported only once for each function it appears in.)

I couldn't understand why TC compiled and why dev c++ not...

So, I think I should try more interesting methods for drawing. :p
 
J

jacob navia

OziRus said:
Thanks for your reply;




Dev C++ couldn't compile the same code that I used with TC. The errors
were like this;

C:\Tc\BIN\KARAKTER.CPP:4: error: expected init-declarator before '*'
token
C:\Tc\BIN\KARAKTER.CPP:4: error: expected `,' or `;' before '*' token
C:\Tc\BIN\KARAKTER.CPP: In function `void _writec(int, int, int)':
C:\Tc\BIN\KARAKTER.CPP:9: error: expected primary-expression before
"char"
C:\Tc\BIN\KARAKTER.CPP:9: error: expected `;' before "char"

C:\Tc\BIN\KARAKTER.CPP:10: error: `scrp' undeclared (first use this
function)
C:\Tc\BIN\KARAKTER.CPP:10: error: (Each undeclared identifier is
reported only once for each function it appears in.)

I couldn't understand why TC compiled and why dev c++ not...

So, I think I should try more interesting methods for drawing. :p

I repeat:

You can't move characters and show characters in the screen by
assigning the characters to some pointer as you do now.

In MSDOS, the machine looked at that address to show the 80x24
video display (if I remember correctly).

This is NO LONGER THE CASE unless you still run MSDOS.

Then, you can't compile and RUN that.

If you want to stay under windows xp there is a compatibility
library for turbo c console I/O with lcc-win32 called
tcconio.lib

You have there functions like "highvideo" "clrscr" and similar
functions, all of them with the same interface that turbo C
used for text mode.

You can download the lcc-win32 compiler from
http://www.cs.virginia.edu/~lcc-win32

Note that lcc-win32 will NOT compile the above code
either. You will have to change your functions to:
gotoxy() and puttextA() or similar functions

jacob
 
C

Coos Haak

Op Sun, 03 Sep 2006 20:06:15 +0200 schreef jacob navia:
The MSDOS emulation will NOT emulate the writing to screen memory,
as it seems.

But surprisingly it DOES, even under XP. If that gives consoloation ;-)
 
C

Coos Haak

Op Sun, 03 Sep 2006 20:38:15 +0200 schreef jacob navia:
In MSDOS, the machine looked at that address to show the 80x24
video display (if I remember correctly).

This is NO LONGER THE CASE unless you still run MSDOS.

Then, you can't compile and RUN that.

<OT>
I've used TC 2.01 some time ago and it works with W98 and XP. Don't tell us
nonsense.
</OT>
 
J

J. J. Farrell

OziRus said:
This is my first message on this group. I want to ask something about
screen-drawing functions. I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling
with Tc and running in dos might run it? [I didn't try it on linux yet]

Thanks for everything...

#include <stdio.h>
#include <conio.h>

char far *vp=(char far *)0xB0000000;


void _write(int row,int col,int ch)
{
char far *scrp=vp;
scrp+=row*160+col*2;
*scrp=ch;
}

int main()
{
_write(10,10,'t');
_write(10,11,'e');
_write(10,12,'s');
_write(10,13,'t');


return 0;
}

You'd be far better off asking in a group which discusses programming
on MS Windows. comp.lang.c concentrates on the C language itself, and
its aspects and uses which are independent of the system it's running
on. Your program is very dependent on the environment you're using -
for example <conio,h> is not part of C as such. C itself doesn't have
any concept of a screen, and mechanisms you use to control a screen (on
systems which have one) are different on different Operating Systems.

You'll find far more people who are expert on writing programs specific
to MS operating systems in the newsgroups which are dedicated to the
subject.
 
F

Flash Gordon

jacob navia wrote:

Contrary to what *many* people think, MSDOS is dead since more than 10
years, I do not remember exactly when was it, maybe 1995.

Incorrect. Windows95, Windows98 and even WindowsME actually had DOS 7.x
underneath and in all of them (although with ME it was difficult) you
could get them to boot to a DOS prompt without loading Windows at all.

In addition, you still get some stuff distributed as bootable DOS disk
images. Such as BIOS upgrades. Since this has been the case on some new
machines even after the year 2000 there are obviously still some
programs being run under DOS.
Contrary to what many people think, the "DOS WINDOW" is just
an EMULATION of text mode msdos, with the same commands,
etc.
True.

The MSDOS emulation will NOT emulate the writing to screen memory,
as it seems.

<snip>

Definitely not entirely true. I've run old DOS based games that did
graphics and sound using their own built in drivers under XP. It might
not really access the screen, but XP traps the attempt (when used in the
correct way) and renders the expected result inside the applications window.

For further discussion on this please go to a Windows group where they
will know all about the compatibility modes of XP.
 
J

jacob navia

Coos said:
Op Sun, 03 Sep 2006 20:38:15 +0200 schreef jacob navia:




<OT>
I've used TC 2.01 some time ago and it works with W98 and XP. Don't tell us
nonsense.
</OT>

You mean you write into 0xB0000000 and you see the characters
in the screen ???

That would be highly surprising, specially under windows xp
 
F

Flash Gordon

OziRus said:
Hi,

This is my first message on this group. I want to ask something about
screen-drawing functions.

To do screen drawing you need things beyond standard C. So you would be
best off asking in a group dedicated to your platform.
> I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.

When you go to a Windows group you should be more explicit. Tell them
which version of TC etc. They will probably tell you to upgrade to a
more recent version that actually has proper support for XP.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling

far and near are nothing to do with C. They are extensions that some
compilers used to provide.
with Tc and running in dos might run it? [I didn't try it on linux yet]

No chance of it working in Linux unless you run it under a DOS emulator.
Thanks for everything...

#include <stdio.h>
#include <conio.h>

Non-standard header. However, it (and the library that go with it) might
provide some of the facility you want.
char far *vp=(char far *)0xB0000000;

far, as I say, is not part of the C language. In any case, there is no
guarantee your screen (or emulated screen in DOS compatibility mode on
XP is at that location. IIRC the location depended to an extent on the
type of graphics card, CGA, EGA and VGA being at different locations. I
could be wrong. Ask on a DOS group.
void _write(int row,int col,int ch)

Don't use names starting with an underscore. There are some you can use
in some conditions but it is not worth the effort of remembering what
you are allowed to do, far simpler to just avoid them.

<snip>
 
J

Joe Wright

jacob said:
OziRus said:
Hi,

This is my first message on this group. I want to ask something about
screen-drawing functions. I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling
with Tc and running in dos might run it? [I didn't try it on linux yet]

Thanks for everything...

#include <stdio.h>
#include <conio.h>

char far *vp=(char far *)0xB0000000;


void _write(int row,int col,int ch)
{
char far *scrp=vp;
scrp+=row*160+col*2;
*scrp=ch;
}

int main()
{
_write(10,10,'t');
_write(10,11,'e');
_write(10,12,'s');
_write(10,13,'t');


return 0;
}

You have to run under MSDOS, not windows XP.
Why would that be?
Contrary to what *many* people think, MSDOS is dead since more than 10
years, I do not remember exactly when was it, maybe 1995.
May it RIP.
Contrary to what many people think, the "DOS WINDOW" is just
an EMULATION of text mode msdos, with the same commands,
etc.
No it isn't. The "Command Prompt" is the CLI of either or both of
'command.com' or 'cmd.exe' under Windows 2K and/or Windows XP.
The MSDOS emulation will NOT emulate the writing to screen memory,
as it seems.

Maybe a better idea would be to use the console mode with a 32 bit
compiler, and obtain the same result.

So, you have two solutions:

1) Get a better compiler
2) Get MSDOS and run under msdos by booting from a disquette.
You will get many advantages:
Only 640K of memory. No more problems with that huge amount
of RAM that you do not know what to do about
TC IDE will run better and all dos programs will work.

The choice is yours

Of course it is. But I find the NTVDM under 2K and XP to be functional
for my purposes. The idea of a DOS boot diskette is just too brutal.
 
J

jacob navia

Joe said:
jacob said:
OziRus said:
Hi,

This is my first message on this group. I want to ask something about
screen-drawing functions. I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling
with Tc and running in dos might run it? [I didn't try it on linux yet]

Thanks for everything...

#include <stdio.h>
#include <conio.h>

char far *vp=(char far *)0xB0000000;


void _write(int row,int col,int ch)
{
char far *scrp=vp;
scrp+=row*160+col*2;
*scrp=ch;
}

int main()
{
_write(10,10,'t');
_write(10,11,'e');
_write(10,12,'s');
_write(10,13,'t');


return 0;
}

You have to run under MSDOS, not windows XP.
Why would that be?
Contrary to what *many* people think, MSDOS is dead since more than 10
years, I do not remember exactly when was it, maybe 1995.
May it RIP.
Contrary to what many people think, the "DOS WINDOW" is just
an EMULATION of text mode msdos, with the same commands,
etc.
No it isn't. The "Command Prompt" is the CLI of either or both of
'command.com' or 'cmd.exe' under Windows 2K and/or Windows XP.

Yes, that is a better description. But you will agree that this "cli"
has commands like

DIR

that remember me an older system. In that sense it is an emulation of a
previous environment.
Of course it is. But I find the NTVDM under 2K and XP to be functional
for my purposes. The idea of a DOS boot diskette is just too brutal.

<OT>

Why?

Digital research and MAXTOR offer an MSDOS disquette that when
you boot it will test the hard disk. Cute isn't it?

Besides MSDOS under emulation will never be exactly like
the true MSDOS.
 
W

William J. Leary Jr.

This might better be asked in comp.os.msdos.programmer or a windows group.

But...
I know far,dev and near are a bit problematic in xp but i think
compiling with Tc and running in dos might run it?

It should work under a Command Line session (often called a "DOS session")
under XP.

But...
char far *vp=(char far *)0xB0000000;

B0000000 is the Monochrome Display Adapter (MDA) base address.

Some color adapters will emulate the MDA, but most won't. Of the those I've
used, only one (see below).

If you're runing this under Windows, it's going to think it's got a color
adapter of some kind*, so you need B8000000.

I've just compiled your program, as a real mode DOS .EXE, and run it under
MS-DOS 5.0, Windows ME and Windows XP. With B0000000 it only works on the
MS-DOS machine. This one explicitly emulates MDA (as per comment above). If I
use B8000000 it works as expected under all three.

- Bill
____________
* Your display adapter probably has to emulate the Color Graphics Adapter (CGA)
for this to work. The majority of adapters do or, at least, did last time I
shopped around (about six months back).
 
J

jacob navia

Flash said:
jacob navia wrote:




Incorrect. Windows95, Windows98 and even WindowsME actually had DOS 7.x
underneath and in all of them (although with ME it was difficult) you
could get them to boot to a DOS prompt without loading Windows at all.

True, but not under windows xp, the system the OP said he
was using.
In addition, you still get some stuff distributed as bootable DOS disk
images. Such as BIOS upgrades. Since this has been the case on some new
machines even after the year 2000 there are obviously still some
programs being run under DOS.

True. I used one yesterday from MAXTOR. It boots
MSDOS (Digital Research) and tests your MAXTOR hard drive.

<snip>

Definitely not entirely true. I've run old DOS based games that did
graphics and sound using their own built in drivers under XP. It might
not really access the screen, but XP traps the attempt (when used in the
correct way) and renders the expected result inside the applications
window.


Yes, you can change the emulator behavior with the "shortcut properties"
if I remember correctly, and maybe it emulates that hacks too.
For further discussion on this please go to a Windows group where they
will know all about the compatibility modes of XP.

AHHHH

Nostalgia is not what it used to be ...

:)
 
J

jacob navia

William said:
This might better be asked in comp.os.msdos.programmer or a windows group.

But...




It should work under a Command Line session (often called a "DOS session")
under XP.

But...




B0000000 is the Monochrome Display Adapter (MDA) base address.

Some color adapters will emulate the MDA, but most won't. Of the those I've
used, only one (see below).

If you're runing this under Windows, it's going to think it's got a color
adapter of some kind*, so you need B8000000.

I've just compiled your program, as a real mode DOS .EXE, and run it under
MS-DOS 5.0, Windows ME and Windows XP. With B0000000 it only works on the
MS-DOS machine. This one explicitly emulates MDA (as per comment above). If I
use B8000000 it works as expected under all three.

- Bill
____________
* Your display adapter probably has to emulate the Color Graphics Adapter (CGA)
for this to work. The majority of adapters do or, at least, did last time I
shopped around (about six months back).

Bill (Your second names isn't Gates I presume ? :)

You are a TRUE MSDOS HACKER (tm)

This is actually the reason!!!!

Congratulations Bill.

jacob
 
C

Coos Haak

Op Sun, 03 Sep 2006 23:14:09 +0200 schreef jacob navia:
You mean you write into 0xB0000000 and you see the characters
in the screen ???

That would be highly surprising, specially under windows xp

<OT>
I would not do that, but writing to 0xB800:0000 still has effect.
Mind you, TC is a 16 bit application. It can't write to a 32 bit long
address.
</OT>
 
W

William J. Leary Jr.

jacob navia said:
Bill (Your second names isn't Gates I presume ? :)

No. "Junior" was born two days after me.
You are a TRUE MSDOS HACKER (tm)

I did a great deal of CP/M and MS-DOS programming. A lot of it direct to
hardware, mostly in K&R C and assembler. Still do some MS-DOS stuff, but in
(almost)ANSI-C and Oberon these days.
This is actually the reason!!!!

Congratulations Bill.

Thanks.

- Bill
 
K

Keith Thompson

OziRus said:
This is my first message on this group. I want to ask something about
screen-drawing functions. I wrote and compiled below code succesfully
on TC IDE in Win-xp. Then i tried to work it on dos but it didn't work.
It runs but doesn't draw anything on screen. Could you say my fault? I
know far,dev and near are a bit problematic in xp but i think compiling
with Tc and running in dos might run it? [I didn't try it on linux yet]

Thanks for everything...

#include <stdio.h>
#include <conio.h>

char far *vp=(char far *)0xB0000000;


void _write(int row,int col,int ch)
{
char far *scrp=vp;
scrp+=row*160+col*2;
*scrp=ch;
}

int main()
{
_write(10,10,'t');
_write(10,11,'e');
_write(10,12,'s');
_write(10,13,'t');


return 0;
}

Apart from the system-specificity of your code, it's a bad idea to use
identifiers starting with an underscore:

All identifiers that begin with an underscore and either an
uppercase letter or another underscore are always reserved for any
use.

All identifiers that begin with an underscore are always reserved
for use as identifiers with file scope in both the ordinary and
tag name spaces.
 
K

Keith Thompson

jacob navia said:
You have to run under MSDOS, not windows XP.

Contrary to what *many* people think, MSDOS is dead since more than 10
years, I do not remember exactly when was it, maybe 1995.

Contrary to what many people think, the "DOS WINDOW" is just
an EMULATION of text mode msdos, with the same commands,
etc.
[snip]

Contrary to what jacob navia seems to think, this newsgroup discusses
the C programming language, not MSDOS or Windows.

There are plenty of newsgroups that do discuss those operating
systems. The OP's question, and jacob's answer, would be appropriate
in one of them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top