Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Conio questions

This thread is locked; no one can reply to it. rss feed Print
Conio questions
Yan Zhang
Member #2,962
November 2002

Heh, I used to use Borland C a long ago when he was in class. Anyway. I wrote a bunch of old games in text mode with the aid of conio.h.

Well, now I use Dev-cpp 4.0 with MingW 1.0. I can't compile my old programs (though I'm really nostalgic about this! ) with dev-cpp because the included conio.h in the ming package doesn't have support for functions like gotoxy, getch, or clrscr(). I hadd some really simple oldschool text games (80 * 25, where I use cin and cout to do i/o, how cool is that?) and I just really would like to see them again.

Is there another header that I can acquire to do things in textmode? Sure, I can simulate each gotoxy and a cout with a textprintf, and each getch with a keypressed(), etc. but that would be such a hassle. I just want to compile something :-p

-Yan

Evert
Member #794
November 2000
avatar

The problem is that the conio functions are a DOS-specific extension. You have basically two options: you can write a conio wrapper around a platform independent console library such as ncurses (my recommendation), which will make your code platform independent as well, or you can use DJGPP instead of MinGW, which includes Borland's DOS extensions.
This may not be an option if you're using Windows XP, though...

Yan Zhang
Member #2,962
November 2002

Hmm, I do use winXP now. But can you explain your last comment? It sounded mysterious :-p

Meanwhile, the only free curses library I found was PDCurses. It comes with four builds, one for DJGPP, EMX, VC, and I think Watcom. Which one do I use? Do I use VC because its the most similar or something? :-/

-Yan

X-G
Member #856
December 2000
avatar

DJGPP has a tendency to explode at random on Windows XP, for unknown reasons.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Plucky
Member #1,346
May 2001
avatar

You could be in luck with the Dev-C++ 4.0 distribution.

Look in the Lib subdirectory of Dev-C++... there's a conio.o object file. Link to it, and a variety of old conio functions could/should/would work. I suspect the source, conio.c, is in the 'Include' subdirectory. Don't forget to look at conio.h.

AFAIK conio.o doesn't come included with the Dev-c++ 4.9.x (5 beta) distribution, but there shouldn't be a reason one couldn't compile conio.c or perhaps use conio.o from the older distribution.

Yan Zhang
Member #2,962
November 2002

The conio.h I see that came with dev-cpp only has like 10 functions, including getch. It won't however, do gotoxy or text-coloring, which my old thing does. Am I looking at the wrong one?

And... an idea just popped up. I do have Borland lying somewhere (though I don't like to dig things back up really). Can I just use its conio, in some form? Or are they not compatible? If so, how?

Thanks guys!

-Yan

X-G
Member #856
December 2000
avatar

Conio is a DOS terminal system. MinGW is a Windows compiler, but emulates some of the functions supported under DJGPP. Borland headers and libraries are not compatible with MinGW. As mentioned, your best choice would probably be to write a conio wrapper for curses and use that.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Plucky
Member #1,346
May 2001
avatar

Quote:

The conio.h I see that came with dev-cpp only has like 10 functions, including getch. It won't however, do gotoxy or text-coloring, which my old thing does. Am I looking at the wrong one?

Did you find conio.o and/or conio.c in the Dev-C++ 4.0 distribution? The gotoxy(), etc. functions are there. Give it a try.

Yan Zhang
Member #2,962
November 2002

Ahh interesting. I found a conio.c that had the things like gotoxy, which was quite cool. But the conio.h in the same directory didn't. So even if I include conio.h and even conio.o under project options, they won't recognize gotoxy. That was kinda weird... any explanations / more help?

-Yan

Hard Rock
Member #1,547
September 2001
avatar

I think its got to do with the windows console. It is basically there to dump stuff, and for backwards compatibility, and discusing it on another board, this person found that the WINDOWS console, not the compiler, did not support quite a few borland c function, including getch and stuff like that...

basically if you want to do those old borland function, your best off doing them back in dos on good ol borland 3.1.

....

actaully the new borland might somehow support all the old functions in windows, but ive never tried it. why dont you download it from borland.com and give it a shot?

_________________________________________________
Hard Rock
[ Stars Dev Company ][ Twitter ][Global Warming: ARA My TINS 07 Entry][Pong Ultra Website][GifAllegS Ver 1.07]
"Well there's also coolwebsearch but we'll let that be an IE exclusive feature" - arielb on the New Browser Plugins "What's better, HTML or Variables?"

Paul Pridham
Member #250
April 2000
avatar

The other thing you could do is to port the stuff to Allegro, and use the Allegro textout, textprintf, etc. functions (since this is an Allegro forum, after all ;))

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

...get it, coño.h?

Yes, we get that it's off-topic, and I'm surprised no one's deleted it yet (Yoo hoo! Moderators!). Elbowing people in the ribs, winking broadly and saying "har har" has never made a bad joke funnier than the first time around ::)

And after M|B deletes MM's posts, this one can go in the trash too. :-X

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Plucky
Member #1,346
May 2001
avatar

Quote:

Ahh interesting. I found a conio.c that had the things like gotoxy, which was quite cool. But the conio.h in the same directory didn't. So even if I include conio.h and even conio.o under project options, they won't recognize gotoxy. That was kinda weird... any explanations / more help?

I was able to use the functions in conio.c using MinGW 2.0, though MinGW 1.0 should work just as well.

I did not include conio.h, taking advantage of implicit function declarations, though one could paste in function declarations from conio.c.

I compiled my test program as a console program. And I linked with conio.o. The functions seem to work as advertised.

Go to: